0

I am trying to on page load have the first form field to be automatically selected/in focus by using the focus() method in jQuery. This works fine on the deskop - however this doesn't appear to work on iOS in the Safari browser - can anyone suggest why not?

    var el = $('#txtNewUsername').get(0);
    var elemLen = el.value.length;

    el.selectionStart = elemLen;
    el.selectionEnd = elemLen;
    el.focus();
Zabs
  • 13,852
  • 45
  • 173
  • 297

1 Answers1

0

I heard about this problem for many times.

This might be helpful Mobile Safari: Javascript focus()

Community
  • 1
  • 1
Jax-p
  • 7,225
  • 4
  • 28
  • 58