Try wrapping your code in this code so that it runs AFTER the DOM is ready
$(function(){
so that he becomes
$(function(){ document.getElementById('ID_HTML_wanted').focus(); });
However, your element does not have a .focus () method, if you want REALLY to use jQuery one, use
$(function(){ $("#ID_HTML_wanted").focus(); });
source share