简体   繁体   中英

Error: 'jQuery is not defined'

I have written a script with jQuery. It works with Firefox and GoogleChrome. Only with IE I have this error returned:

'jQuery' is not defined jquery-ui-1.8.4.custom.min.js, Row 10 Character 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 . 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. 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.

The Firefox "TamperData" plugin is really handy for tracking HTTP requests on page loads.

  1. Don't use application/javascript , change to text/javascript

  2. Check the path of jquery
    is your jquery in lib/js/ , or just lib/ ?

  3. Make sure your lib directory is relative to the calling page
    You may have meant /lib/jquery.js (the slash in the beginning makes a difference)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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