2

I'm using jQuery mobile, I now want to make an input text field to be highlighted when tapped.

I'm using this:

$(document).ready(function() {
    $('.highlight').focus(texty_focus);
});
function texty_focus() {
    var input = $(this);
    setTimeout(function() { 
        input.select();
    },10);
}

But it's not working on my mobile. Any suggestions?

4

1 回答 1

5

也许你可以试试这个:

$(document).ready(function() {
     $('.highlight').click(function(){
         var input = this;
         input.focus();
         input.setSelectionRange(0,999); 
     });
});
于 2013-05-18T03:07:06.043 回答