为了清理我的代码,我想在我的实际 jQuery 插件中使用子插件,但实际上没有发生任何事情。提前谢谢
作为一个简单的例子,请看下面的代码:
(function($){
$.fn.funct = function() {
// so far it seems to run the code...
console.log('funct is running...');
return this.each(function(){
// ...but nothing is happening here
console.log('this.each is running...');
$(this).css('background', 'blue');
}
}
$.fn.foo = function() {
return this.each(function(){
console.log('plugin is running...');
$(this).funct();
});
};
})(jQuery);
乍一看,您似乎没有正确关闭第一个返回。
$(this).css('background', 'blue');
}
应该:
$(this).css('background', 'blue');
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)