2012-07-26 62 views
3

有沒有辦法檢查twitter-bootstrapjquery插件是否正常工作?如何檢查引導程序的jquery插件是否正常工作?

+0

你是什麼意思的「檢查」? – Kane 2012-07-26 08:13:58

+0

確認它們是否正常工作。 – 2012-07-26 08:14:46

+1

通過工作你的意思是 - 在瀏覽器X上工作,已經被客戶端下載,在代碼庫中有缺陷嗎? – Kane 2012-07-26 08:17:41

回答

1

使用

if (typeof jQuery != 'undefined') { 

    alert("jQuery library is loaded!"); 

}else{ 

    alert("jQuery library is not found!"); 

} 

if (jQuery) { 

    alert("jQuery library is loaded!"); 

} else { 

    alert("jQuery library is not found!"); 

} 
+0

抱歉,但我是前端的新東西。究竟在哪裏運行這個代碼? – 2012-07-26 08:35:14

+0

2012-07-26 08:36:36

+1

這並不是專門測試Twitter的引導程序是否已加載。 因爲bootstrap沒有命名空間爲'Bootstrap',所以你必須使用if(jQuery()。Carousel){}。 – bafromca 2012-09-18 16:40:58

0

我遇到了同樣的問題。以下是我如何從CDN加載引導程序或無法在本地加載引導程序。

<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script> 
    <script>if ($('body').popover) { document.write('bootstrap loaded from cdn') } 
      else { document.write('cdn bootstrap failed, going local'); 
        document.write('<script src="js/vendor/bootstrap.min.js"><\/script>') } 
    </script> 
相關問題