[英]Select textbox on focus, deselect on blur
I am trying to select a textbox that has my link to this page url in it. 我正在尝试选择一个文本框,该文本框具有指向该页面URL的链接。 I use: 我用:
$('.linkTo').focus(function() {
this.select();
});
$('.linkTo').blur(function() {
var input_value = this.value;
this.value = input_value;
});
But it only works the first time, the second time it puts a deselected cursor where I clicked. 但是它仅在第一次使用时有效,第二次将未选择的光标放在我单击的位置。
解决方案从问题中删除:
<input onclick="this.select();" class.... />
Try using foucusin()
and focusout()
尝试使用foucusin()
和focusout()
http://api.jquery.com/focusin/ http://api.jquery.com/focusin/
http://api.jquery.com/focusout/ http://api.jquery.com/focusout/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.