你好,我有這個代碼的問題: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'。 –