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,579
  • 8
  • 53
  • 86
Aerodynamika
  • 7,883
  • 16
  • 78
  • 137

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