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,252
  • 42
  • 158
  • 277

1 Answers1

0

I heard about this problem for many times.

This might be helpful Mobile Safari: Javascript focus()

Community
  • 1
  • 1
Jax-p
  • 5,223
  • 2
  • 20
  • 50