jquery回调函数
我使用 recaptcha
Recaptcha.create("xxx", "recaptcha", {
theme: 'clean',
tabindex: 0,
callback: $("#id").focus
});
我想使用回调来聚焦某些字段,但它不起作用,只有 callback: f
有效,
function f() {
$("#FIO").focus();
}
问题是什么?
i use recaptcha
Recaptcha.create("xxx", "recaptcha", {
theme: 'clean',
tabindex: 0,
callback: $("#id").focus
});
i want to use callback to focus some field, but it doesn't work, only callback: f
works
function f() {
$("#FIO").focus();
}
what is the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
回调必须是一个函数。您尝试执行 $() 函数并引用它的 focus 方法。那是行不通的。试试这个。
The callback needs to be a function. What you have attempts to execute the $() function and reference the focus method of it. That won't work. Try this.
您确定语句
$("#FIO").focus()
的结果在各个范围内一致吗?或者试试这个?
callback: function() { $("#FIO").focus(); }
Are you sure the result of the statement
$("#FIO").focus()
is consistent across scopes?or try this?
callback: function() { $("#FIO").focus(); }
focus()
也是 javascript 的本机函数,您可以通过以下任一方式执行
The
focus()
is also native function of javascript, you can do in either wayor