简体   繁体   English

错误:'jQuery未定义'

[英]Error: 'jQuery is not defined'

I have written a script with jQuery. 我用jQuery编写了一个脚本。 It works with Firefox and GoogleChrome. 它适用于Firefox和GoogleChrome。 Only with IE I have this error returned: 只有使用IE我才会返回此错误:

'jQuery' is not defined jquery-ui-1.8.4.custom.min.js, Row 10 Character 1 'jQuery'未定义为jquery-ui-1.8.4.custom.min.js,第10行字符1

This is the head of my page: 这是我页面的负责人:

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Contattaci - TheItalianBrand.com</title>
    <script type="text/javascript" src="lib/jquery.js"></script>
    <script type="text/javascript" src="lib/js/jquery-ui-1.8.4.custom.min.js"></script>
    <link type="text/css" href="lib/css/smoothness/jquery-ui-1.8.4.custom.css" rel="stylesheet" /> 
    <script type="application/javascript">
       $(function(){



    $('#dialog_link, ul#icons li').hover(
     function() { $(this).addClass('ui-state-hover'); }, 
     function() { $(this).removeClass('ui-state-hover'); }
    );

    $('input').change(function() {
      validate();
    });
    $('input').keydown(function() {
      validate();
    });
    $('textarea').change(function() {
      validate();
    });
    $('textarea').keydown(function() {
      validate();
    });
   });
   </script>
   </head>

What can I do? 我能做什么?

您必须检查添加的jQuery的序列,并以适当的顺序添加jQuery库

You're importing the jQuery UI library from lib/js , but jQuery itself from lib . 要导入从jQuery UI的库lib/js的,但它本身的jQuery lib I suspect that your copy of the jQuery library is also in lib/js and that you're just not getting it due to that incorrect path. 我怀疑你的jQuery库的副本也在lib/js ,而你却因为错误的路径而得不到它。 Of course, that would mean that it's not actually working in Firefox or Chrome or any other browser, but it could be that they're just less strident about error reporting so you're not noticing. 当然,这意味着它实际上并不适用于Firefox或Chrome或任何其他浏览器,但可能是因为它们在错误报告方面不那么尖锐,所以你没有注意到。

The Firefox "TamperData" plugin is really handy for tracking HTTP requests on page loads. Firefox“TamperData”插件非常便于在页面加载时跟踪HTTP请求。

  1. Don't use application/javascript , change to text/javascript 不要使用application/javascript ,更改为text/javascript

  2. Check the path of jquery 检查jquery的路径
    is your jquery in lib/js/ , or just lib/ ? lib/js/ jquery,还是lib/

  3. Make sure your lib directory is relative to the calling page 确保您的lib目录相对于调用页面
    You may have meant /lib/jquery.js (the slash in the beginning makes a difference) 你可能意味着/lib/jquery.js (开头的斜线有所不同)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM