I'm trying understand how element focus works.
My questions is:-
Does Javascript focus have some limitations? I mean does it have same permissions when it runs from website code and from debug console?
also does focus depends on user action? Because I have code example which I can't understand why it runs like this:-
$('document').ready(function() {
$('#username').focus();
$("#username").focus(function() {
$('.placeholder').hide();
});
$('#ss').click(function() {
$('#username').focus();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<div class="placeholder_input">
<input type="text" id="username" maxlength="100" />
<div class="placeholder_container">
<div class="placeholder">username</div>
<div id='ss'> damc</div>
</div>
</div>
Example On JSFiddle
When code starts run it must focus input field and hide text but it not doing this can't understand why? But when I'm making click on text then it makes focus on input field and hides text. Why it can't hide in beginning? Is it some kind of limitation?