为了账号安全,请及时绑定邮箱和手机立即绑定

检查是否使用Javascript加载了jquery

检查是否使用Javascript加载了jquery

慕的地8271018 2019-08-12 11:35:53
检查是否使用Javascript加载了jquery我正在尝试检查我的Jquery库是否已加载到我的HTML页面上。我正在检查它是否有效,但有些事情是不对的。这是我有的:<html xmlns="http://www.w3.org/1999/xhtml">     <head>         <script type="text/javascript" src="/query-1.6.3.min.js"></script>         <script type="text/javascript">           $(document).ready(function(){              if (jQuery) {                  // jQuery is loaded                  alert("Yeah!");              } else {                // jQuery is not loaded                alert("Doesn't Work");              }           });         </script>
查看完整描述

3 回答

?
qq_花开花谢_0

TA贡献1835条经验 获得超6个赞

if (typeof jQuery == 'undefined') {
    // jQuery IS NOT loaded, do stuff here.}
if (typeof jQuery == 'function')//orif (typeof $== 'function')


if (jQuery) {
    alert("jquery is loaded");} else {
    alert("Not loaded");}

希望这能涵盖完成这项工作的所有好方法!


查看完整回答
反对 回复 2019-08-12
?
杨魅力

TA贡献1811条经验 获得超5个赞

if ('undefined' == typeof window.jQuery) {

    // jQuery not present

} else {

    // jQuery present

}


查看完整回答
反对 回复 2019-08-12
  • 3 回答
  • 0 关注
  • 425 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信