开发者

jquery / jquery ui : $ is undefined

开发者 https://www.devze.com 2023-03-22 00:41 出处:网络
I have a file that i think is jQuery UI. It mentions jQuery in the code but it is condensed, so it\'s hard to tell.

I have a file that i think is jQuery UI. It mentions jQuery in the code but it is condensed, so it's hard to tell.

I included both jquery1.6.2.js and custom.js. (confirmed that they are both loading properly)

There is a sliding image panel that works fine when both are included, although I do get the message: $ is undefined from my own code (not the custom.开发者_如何转开发js)

I read somewhere that the problem might be that I need to not include jQuery, but that seems to disable the image slider. The $ function seems to work fine if I remove the custom.js, but then of course the slide doesn't work.

Any ideas?


Make sure that your loading the jQuery library before you load any other JavaScript that relies on the jQuery library.


Make sure to include jQuery then jQueryUI before any plugins.


  1. Load jQuery before things that depend upon it

  2. Make sure jQuery is bound to window.$ (might not be with noConflict)

From the statement:

the $ function seems to work fine if i remove the custom.js

Then I believe that either custom.js is loaded before jQuery or the problem lies in custom.js: in particular, it is likely muddling with window.$ -- through jQuery.noConflict or otherwise. However, a test-case is required to say more with confidence.

Happy coding.

0

精彩评论

暂无评论...
验证码 换一张
取 消