jQuery聚焦元素 [英] JQuery focus an element
本文介绍了jQuery聚焦元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在javascript中,以下工作可将焦点移至edit_2输入框:
In javascript the following works to give focus to the edit_2 input box:
document.getElementById("edit_2").focus();
但是使用Jquery却没有:
However using Jquery this does not:
$("#edit_2").focus;
推荐答案
您正在调用方法,因此:
You are calling a method, so:
$("#edit_2").focus;
应该是
$("#edit_2").focus();
编辑:如果您想知道为什么第一行不算作语法错误,那是因为它是一条正确的语句,上面写着获取函数focus
"(并且不执行任何操作) ).
EDIT: If you are wondering why the first line was not counted as a syntax error, it's because it is a correct statement saying "get the function focus
" (and do nothing with it).
这篇关于jQuery聚焦元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文