【发布时间】:2010-11-17 08:28:17
【问题描述】:
为了清理我的代码,我想在我的实际 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);
【问题讨论】:
标签: javascript jquery ajax jquery-plugins