简体   繁体   中英

$ undefined error

I'm developing a Chrome extension and I've got the following...

 $(document).keypress(function(event){ resizeDialogIFrame(overlaydiv, iFrame.contentWindow); });

But when executed I'm getting the following error...

Uncaught ReferenceError: $ is not defined

However, $('form[name="gs"]').attr('action'); is working fine elsewhere in the page.. What's going wrong?

If jQuery was loaded correctly (?) try this pattern to make sure $ references the jQuery object.

(function($) {
     $(function() {
         $(document).keypress(function(event){ resizeDialogIFrame(overlaydiv, iFrame.contentWindow); });
     });
}(jQuery));

If that doesn't help, check if jQuery was loaded correctly. Thatfore, call

alert('jQuery' in window);

if that alerts false , something is wrong.

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