.select () does not work on iOS device

I would like to make an input window that, when the user selects it, selects all the text in the field. So I decided to use the select() function, which I would like to achieve. However, it works as I expected on desktop browsers, but not on Safari on the iPad. How to solve the problem? Thanks.

 $('#input').click(function(e){ $(this).select(); }); 
+8
javascript jquery html mobile mobile-safari
source share
1 answer

according to this SO question ( Programmatically select text in input field on iOS devices (mobile Safari) ), it does not work on iOS, and you need to use the setSelectionRange() function. in your case it will be something like this:

 $(this).get(0).setSelectionRange(0,9999); 
+16
source share

All Articles