views:

174

answers:

2

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.

+6  A: 

It's hard to prove a negative, but my research suggests this is a bug in Mobile Safari, possibly at the level of WebKit.

Note that focus() works, more or less—though it can require more than one tap to succeed, and it's not necessary if you're trying to respond to a user tap on the field in question as the tap itself will give the field focus. Unfortunately, select() is simply non-functional in Mobile Safari.

Your best bet may be a bug report to Apple and/or WebKit.

clozach
Our testing indicates the same. It's a bug/missing-feature in mobile safari.
Nir Levy
A: 

Same here.. there seem to be a lot of methodes not working in Mobile Safari .select() and .focus() are two of those.

jeroenvduffelen