iOS has an unusual behavior when it comes to focusing elements.
You can only focus element from JS when focus is initiated from user action, such as clicking somewhere.
However, iOS will also report element as being in focus, when Safari has prevented focus and element is not in focus.
Example:
$(function() {
$('#sad').focus();
});
#sad {
background-color: red;
}
#sad:focus {
background-color: green;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="sad">
The input is green on page load on my iPad, but there is no keyboard.
I need to know when element actually has focus. Is there any other way?