0
我正在寫一個jQuery插件,它需要依賴jQuery ++,但我不確定如何從插件引用它。我該怎麼做?如何使用另一個jQuery插件?
我正在寫一個jQuery插件,它需要依賴jQuery ++,但我不確定如何從插件引用它。我該怎麼做?如何使用另一個jQuery插件?
試試這個:
(function($){
$.fn.funct = function() {
console.log('funct is running...');
}
$.fn.foo = function() {
return this.each(function(){
console.log('plugin is running...');
$(this).funct();
});
};
})(jQuery);
修改您可以嘗試使用jQuery.getScript()
$.getScript("other_scripts.js", function(){
// You can use anything you defined in other_scripts.js here
});
只要其他插件這一塊之前加載,它應該工作一般。也許如果你舉了一個你想要做什麼的例子? – JJJ 2013-05-08 09:52:47
@Juhana我正要寫這個;) – 2013-05-08 09:56:57
唉,原來我只是使用插件錯誤,現在感覺像個白癡。對不起大家! – tsvallender 2013-05-08 10:03:54