如何在 jQuery 中声明这个函数? $(document).ready 不起作用
我正在使用 FCBKcomplete。我不知道为什么我的 UI 不接受 $(document).ready
下触发的任何函数。
我必须为 Facebook 触发以下功能,例如自动完成,就像 http://www.emposha 一样。 com/demo/fcbkcomplete_2/
$(document).ready(function() {
$("#select3").fcbkcomplete({
json_url: "data.txt",
addontab: true,
maxitems: 10,
input_min_size: 0,
height: 10,
cache: true,
newel: true,
select_all_text: "select"
});
});
但它不起作用。其他事件,例如 click
、blur
等都在我的 UI 中正常工作。我可以使用任何替代函数来代替 document.ready
吗?
I am using FCBKcomplete. I don't know the reason why my UI is not accepting any function triggered under $(document).ready
.
I have to trigger the function below for Facebook like auto-complete, just like http://www.emposha.com/demo/fcbkcomplete_2/
$(document).ready(function() {
$("#select3").fcbkcomplete({
json_url: "data.txt",
addontab: true,
maxitems: 10,
input_min_size: 0,
height: 10,
cache: true,
newel: true,
select_all_text: "select"
});
});
But it's not working. Other events, such as click
, blur
and all are working fine in my UI. Is there any alternative function which I can use instead of document.ready
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许 javascript 库的其他一些包含已经使用 $(美元符号)作为选择器。因此,如果您收到
$(document).ready is not a function
错误或类似错误(例如您的$("#select3").fcbkcomplete is not a function
) ,您必须构建“bodyguard”功能,例如:Maybe some other include of a javascript library is using the $ (dollar sign) already as a selector. So if you get the
$(document).ready is not a function
error or similar ones (like your$("#select3").fcbkcomplete is not a function
), you'll have to build in a "body guard" functionality like:fcbkcomplete()
函数中最后一个选项 (select_all_text
) 后面不应有逗号。There shouldn't be a comma after the last option (
select_all_text
) in thefcbkcomplete()
function.