thedjaney
thedjaney

Reputation: 1126

jQuery object is undefined after ready

I have a weird problem with jQuery, the "$" becomes undefined after executing all the code under the ready event.

Any experience in this error? or any idea what is causing this?

Upvotes: 0

Views: 777

Answers (2)

M.I.T.
M.I.T.

Reputation: 1042

use like this

<script type="text/javascript">
    var $ = jQuery.noConflict();
    (function ($) {
           $(document);
           // your code
    }(jQuery));
</script>

Upvotes: 0

Rosmarine Popcorn
Rosmarine Popcorn

Reputation: 10967

Put jQuery code inside this snipet, because $ might be defined for something else.

(function($) {

    // $ Works! You can test it with next line if you like
    // console.log($);

})( jQuery );

Upvotes: 1

Related Questions