Reputation: 3209
I got this code here...
<script type="text/javascript">
$('document').ready(function() {
alert($('.thickbox'));
});
</script>
and I put this code in my wordpress theme footer.php file at the bottom. When I went to my page, the alert did not appear, I check my error console and found this error
TypeError: $ is not a function
$('document').ready(function() {
what gives? my jquery file is in the header, so this should work...or is there a specfic way to put jquery in wordpress?
Upvotes: 1
Views: 829
Reputation: 18042
Wordpress's packaged jQuery defaults to noConflict
mode, use jQuery('document')
, or wrap your code like
(function($) {
// Code that uses jQuery's $ can follow here.
})(jQuery);
or in your document ready like this:
jQuery(document).ready(function($) {
// Code that uses jQuery's $ can follow here.
});
Upvotes: 6
Reputation: 3219
'$' is just an alias for 'jQuery'. if $('document')
isn't working, try jQuery('document')
Upvotes: 1
Reputation: 3949
try jQuery instead of $
jQuery('document').ready(function($){
alert($('.thickbox'));
});
Upvotes: 1