jQuery的重点是负载 [英] jquery focus on load
本文介绍了jQuery的重点是负载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
document.getElementById('ID_HTML_wanted')。focus();
但是我的html元素ID_HTML_wanted因为不是重点。我用户jquery api .focus 解决方案
尝试将代码包装到此代码中,以便它执行AFTER DOM准备就绪
$(函数(){
//你的代码
});
所以它会变成
$(function(){
document.getElementById('ID_HTML_wanted')。focus();
});
然而,你的元素没有.focus()方法,如果你想要真正的使用jQuery的一个,使用
$(function(){
$(#ID_HTML_wanted)。 ;
});
How to set the focus on a html element ?
I use document.getElementById('ID_HTML_wanted').focus();
but my html element "ID_HTML_wanted" as not the focus. I user jquery api .focus
解决方案
Try to wrap your code to this code so it executes AFTER DOM is ready
$(function(){
//your code
});
so it will become
$(function(){
document.getElementById('ID_HTML_wanted').focus();
});
However, your element't don't have .focus() method, if you want to REALLY use jQuery's one, use
$(function(){
$("#ID_HTML_wanted").focus();
});
这篇关于jQuery的重点是负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文