title: Mobile Safari: Javascript focus() method on inputfield only works with click?
body: <p>I have a simple input field like this.</p>
  
  <pre><code>&lt;div class="search"&gt;
     &lt;input type="text" value="y u no work"/&gt;
  &lt;/div&gt;​
  </code></pre>
  
  <p>And I'm trying to <code>focus()</code> it inside a function.
  So inside of a random function (doesn't matter what function it is) I have this line …</p>
  
  <pre><code>$('.search').find('input').focus();
  </code></pre>
  
  <p>This works just fine on every Desktop whatsoever.</p>
  
  <p>However it doesn't work on my iPhone. The field is not getting focused and the keyboard is not shown on my iPhone.</p>
  
  <p>For testing purposes and to show you guys the problem I did a quick sample:</p>
  
  <pre><code>$('#some-test-element').click(function() {
    $('.search').find('input').focus(); // works well on my iPhone - Keyboard slides in
  });
  
  setTimeout(function() {
    //alert('test'); //works
    $('.search').find('input').focus(); // doesn't work on my iPhone - works on Desktop
  }, 5000);​
  </code></pre>
  
  <p>Any idea why the <code>focus()</code> wouldn't work with the timeout function on my iPhone.</p>
  
  <p>To see the live example, test this fiddle on your iPhone. <a href="http://jsfiddle.net/Hc4sT/" rel="noreferrer">http://jsfiddle.net/Hc4sT/</a></p>
  
  <p><strong>Update:</strong></p>
  
  <p>I created the exact same case as I'm currently facing in my current project.</p>
  
  <p>I have a select-box that should — when "changed" — set the focus to the input field and slide-in the kexboard on the iphone or other mobile devices. I found out that the focus() is set correctly but the keyboard doesn't show up. I need the keyboard to show up.</p>