你好,我有这个代码的问题:JS工作在浏览器中,但不是的jsfiddle
$("#col3, #col4").betterMouseover(500, function() {
var color;
if ($(this).attr('id') == "col3") { color = "#44a0ff"; }
else { color = "red"; }
$("#better").css({backgroundColor:""+color+""});
});
(function($) {
$.fn.betterMouseover = function (accidentTime, funkcia) {
if (accidentTime == undefined || accidentTime == null) { accidentTime = 250; }
if (funkcia == undefined || funkcia == null || typeof funkcia != 'function') {
funkcia = function() {
console.log("no callback action specified for betterMouseover()");
};
}
return this.each(function() {
var jeOut;
$(this).mouseenter(function() {
var totok = this;
jeOut = false;
setTimeout(function(){
if (!jeOut) { $(totok).betterMouseoverHandler(funkcia); }
}, accidentTime);
}).mouseleave(function() {
jeOut = true;
});
});
}
$.fn.betterMouseoverHandler = function (fx) {
fx.call(this);
}
}(jQuery));
代码在浏览器中,但不是的jsfiddle。这是我的小jQuery插件maden,我在第9行得到错误,说什么Object对象没有方法betterMouseover。 在JSFiddle中是否有一些限制,所以我无法运行jquery插件?
你意识到你想存在之前使用的插件,对不对?你在jsfiddle上得到同样的错误。 '警报(FOO); var foo =“bar”;'会给你'undefined'。 –