我有一个 jQuery 插件 tzineClock。但是当我尝试调用它时
$(document).ready(function(){
/* This code is executed after the DOM has been completely loaded */
$('#fancyClock').tzineClock();
});
它正在抛出错误,因为“不支持此功能”。谁能告诉我错误可能是什么?这是 tzineClock 代码:
$.fn.tzineClock = function(opts){
// "this" contains the elements that were selected when calling the plugin: $('elements').tzineClock();
// If the selector returned more than one element, use the first one:
var container = this.eq(0);
if(!container)
{
try{
console.log("Invalid selector!");
} catch(e){}
return false;
}
if(!opts) opts = {};
var defaults = {
/* Additional options will be added in future versions of the plugin. */
};
/* Merging the provided options with the default ones (will be used in future versions of the plugin): */
$.each(defaults,function(k,v){
opts[k] = opts[k] || defaults[k];
})
// Calling the setUp function and passing the container,
// will be available to the setUp function as "this":
setUp.call(container);
return this;
}
最佳答案
这可能是因为 jQuery 尚未加载 tzineClock 函数,因此它“不受支持”。
检查您引用插件的脚本标签,并确保 tzineClock 脚本标 checkout 现在 jQuery 脚本标签之前。
如果这没有什么区别,您能否向我们提供导致错误的行和文件,并确保脚本文件已使用任何浏览器开发工具实际加载.
关于javascript - jquery函数不支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8308594/