3

twitter-bootstrapjqueryプラグインが正常に動作しているかどうかを確認する方法はありますか?

4

4 に答える 4

2

使用する

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!");

}
于 2012-07-26T08:33:18.300 に答える
1

A much better answer is already here: How to check if Twitter Bootstrap is Loaded. If jQuery is also having problems, such as if the "$" character is not defined when you run the code from the link above, or if you want to check if jQuery itself is loading, try here: jQuery is not defined.

于 2015-07-29T00:49:41.170 に答える
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>
于 2012-09-19T14:51:45.060 に答える