简体   繁体   中英

head.js and jQuery issues in Chrome / Firefox 5

So the page is rendered like this:

<!DOCTYPE html>
<html>

<head>
  <script>

   head.js("js/jquery.js",
           "js/jquery.autocomplete.js");

  </script>
</head>

<body>

  ...
  stuff here
  ...

  <script>

    jQuery(document).ready(function($){  // fail...

      $('body').removeClass('no-jquery');
      // ...

    });
  </script>
</body>
</html>

The scripts seem to load and all in Opera, but in Firefox 5 and Chrome (don't know the version because it changes every day) I get a error:

jQuery is not defined
[Break On This Error] jQuery(document).ready(function($){ 

So I guess jquery is not really loaded by head.js in these browsers? Or I'm doing something wrong?


jsfiddle: http://jsfiddle.net/LDUUd/

Try switching to head.ready() instead of jQuery.ready() .

Here is an example of it working - is this what you have?

You're calling head.js() without

<!-- assuming it's in the same directory as the page -->
<script src="head.min.js"></script>

first.

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