爲了清理我的代碼,我想在我的實際jQuery插件中使用子插件,但實際上沒有任何事情發生。 THX提前在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);
哇,好趕上! – 2009-08-06 13:26:57