开发者

Select textbox on focus, deselect on blur

开发者 https://www.devze.com 2023-03-05 22:06 出处:网络
I am try开发者_StackOverflow中文版ing to select a textbox that has my link to this page url in it.I use:

I am try开发者_StackOverflow中文版ing to select a textbox that has my link to this page url in it. 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.


Try using foucusin() and focusout()

http://api.jquery.com/focusin/

http://api.jquery.com/focusout/


Solution edited out from the question:

<input onclick="this.select();" class.... />
0

精彩评论

暂无评论...
验证码 换一张
取 消