How do you programmatically select the text of an input field on iOS devices, e.g. iPhone, iPad running mobile Safari?
Normally it is sufficient to call the .select()
function on the <input ... />
element, but this does not work on those devices. The cursor is simply left at the end of the existing entry with no selection made.
input.setSelectionRange(0, 9999);
https://developer.mozilla.org/en/DOM/Input.select
Nothing in this thread worked for me, here's what works on my iPad:
// t is the input field setTimeout(function() { t.setSelectionRange(0, 9999); }, 1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With