我正在使用 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
吗?
最佳答案
也许 javascript 库的其他一些包含内容已经使用 $(美元符号)作为选择器。因此,如果您收到 $(document).ready is not a function
错误或类似错误(例如您的 $("#select3").fcbkcomplete is not a function
) ,您必须构建“bodyguard”功能,例如:
( function($) {
// we can now rely on $ within the safety of our “bodyguard” function
$(document).ready( function() {
alert("Yay I can use '$'!!");
} );
} ) ( jQuery );
关于javascript - 如何在 jQuery 中声明这个函数? $(document).ready 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8666467/