We have following HTML:
<div>
<span>
<span id="Container1" tabindex="1" >Container1</span>
</span>
</div>
<span id="Container2" tabindex="2" >Container2</span>
And we need set focus to the Container2 <span>
element when page is loaded.
I tried following jquery:
$(document).ready( function(){
$("#Container2").focus();
});
It works fine in the Chrome (Version 35.0.1916.153) and IE9. But in the Firefox (v. 30.0) it doesn't work. According to this question I also tried
$(document).ready( function(){
setTimeout(function () {
$("#Container2").focus();
}, 0);
});
and
$(document).ready( function(){
setTimeout(function () {
$("#Container2").trigger('focus');
}, 0);
});
but it is the same result.
Also it isn't possible select element with mouse click until we press TAB button.
I looked over this question and it seems focus is set properly but outline is not rendered.
Is it any way to set default focus in Firefox?