0

I have the following code to select all the contents of my input element that has id="embedurl"

$('#embedurl').focus(function(event) {
    setTimeout(function() {
        $('#embedurl').select();
    }, 0);
});

It works fine on desktop, but in iOS nothing gets selected.

Any idea how I could fix that?

Thanks!

Ziem
  • 6,351
  • 7
  • 51
  • 85
Aerodynamika
  • 7,133
  • 14
  • 65
  • 120

1 Answers1

1

Try:

$('#embedurl').setSelectionRange(0, 9999);

From this answer. It worked for me, although the comments on that answer do note some caveats, such as needing to trigger a focus() event first.

Community
  • 1
  • 1
Mike Kemp
  • 31
  • 4