How to check if Twitter bootstrap is loaded?

前端 未结 9 910
礼貌的吻别
礼貌的吻别 2020-12-07 14:32

How can I check whether there is a bootstrap.js loaded on page (a file bootstrap.js may be compiled into another big JS file)?

9条回答
  •  忘掉有多难
    2020-12-07 14:58

    I would rather check for specific bootstrap plugin since modal or tooltip are very common, so

    if(typeof($.fn.popover) != 'undefined'){
     // your stuff here
    }
    

    or

     if (typeof $.fn.popover == 'function') { 
       // your stuff here
      }
    

    works in both bootstrap versions

提交回复
热议问题