我在一些頁面中有一個插件,但在其他一些頁面中,我不需要它,所以我沒有引用它的腳本文件。如何檢查jQuery插件和函數是否存在?
如何在使用前檢查插件功能是否存在。
在我來說,我使用這個插件:我用它是這樣的:
$('#marquee-inner div').marquee('pointer').mouseover(function() {
$(this).trigger('stop');
}).mouseout(function() {
$(this).trigger('start');
}).mousemove(function(event) {
if ($(this).data('drag') == true) {
this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
}
}).mousedown(function(event) {
$(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
}).mouseup(function() {
$(this).data('drag', false);
});
我要的是,如果它存在,或者不調用此函數字幕之前進行檢查。
可能的重複[如何檢查是否加載了jQuery插件?](http://stackoverflow.com/questions/400916/how-can-i-check-if-a-jquery-plugin-is-加載) – toxalot 2013-11-23 06:29:18
[詳細文章檢查jQuery或jQuery插件是否加載](http://conceptf1.blogspot.com/2013/11/jquery-library-loaded-or-not-validation.html) – 2013-12-10 17:24:15