2013-05-08 38 views
0

我正在写一个jQuery插件,它需要依赖jQuery ++,但我不确定如何从插件引用它。我该怎么做?如何使用另一个jQuery插件?

+2

只要其他插件这一块之前加载,它应该工作一般。也许如果你举了一个你想要做什么的例子? – JJJ 2013-05-08 09:52:47

+0

@Juhana我正要写这个;) – 2013-05-08 09:56:57

+0

唉,原来我只是使用插件错误,现在感觉像个白痴。对不起大家! – tsvallender 2013-05-08 10:03:54

回答

0

试试这个:

(function($){ 
    $.fn.funct = function() { 
     console.log('funct is running...'); 
    } 
    $.fn.foo = function() { 
     return this.each(function(){ 
      console.log('plugin is running...'); 
      $(this).funct(); 
     }); 
    }; 
})(jQuery); 

代码复制,并从Calling other plugins within a jQuery plugin

1

修改您可以尝试使用jQuery.getScript()

$.getScript("other_scripts.js", function(){ 

    // You can use anything you defined in other_scripts.js here 

}); 
相关问题