jquery / jquery ui : $ is undefined
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.
Load jQuery before things that depend upon it
Make sure jQuery is bound to
window.$
(might not be withnoConflict
)
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.
精彩评论