jQuery是否存在于当前页面中

Whether jQuery exists in the current page or not

本文关键字:当前页 是否 存在 jQuery      更新时间:2023-09-26

检查jQuery脚本是否已包含在页面中的最佳方法是什么?我有一个,但我认为它不优雅。

try { $("body") } catch(e) { /* doesn't exist */ }

像这样:

if(window.jQuery)
{
    //jquery found 
}