0

I have a change event on a select that should focus on the next input (text input) and select all its text. I tried:

$('#myselect').change(function () {
    //Doing some extra operations

    var $hours = $('#myinput');
    $hours.focus(function () {
        this.setSelectionRange(0, 999);
    })
    $hours.focus();
}

This works perfectly on desktop (tested on chrome) but not completely in safari (tested on iphone 5s and ipad2).

In particular, the input gets the focus, but the keyboard doesn't open, and if I click elsewhere then the keyboard opens and the text inside the input is selected.

How can I fix this?

Phate01
  • 2,499
  • 2
  • 30
  • 55

1 Answers1

0

You will need a bit more complicated approach for mobile devices.

Community
  • 1
  • 1
DDan
  • 8,068
  • 5
  • 33
  • 52
  • According to the first post I should not trying to focus it, and the second one provides a way that didn't worked for me. What should I do? – Phate01 Jul 03 '15 at 10:16