Forums

jQuery in WordPress!

Hi all,
I’ve been building a site with wordpress and came across a bit of a problem trying to insert a jquery script to the header.
Apparently it doesn’t like the $ and won’t recognise any function with the $ before it! I was adding this between some script tags.

Code:

$(document).ready(function(){
< ------ stuff here -----/>
});

No luck! After a lot of head scratching i found an article that recommended this instead.

Code:

jQuery(document).ready(function($) {
< ------ stuff here -----/>
});

Works like a charm. You can now use the $ inside the document.ready function. It’s to do with other javascript librarys used in WordPress so they don’t conflict. I’d never heard of this so i hope it’s useful to someone else!