I have been using wordpress for a while and now I’m starting to integrate more jQuery into some of my blogs. Problem is I have been having problems with the code acting up. After searching I found the jQuery is now included in the core code for wordpress. More reading and I found that I need to use jQuery’s noConflict to make my code work in wordpress. Using noConflict your code will look like this:
$j = jQuery.noConflict();
$j(function() {
$j("#sidebar #trigger").click(function(event) {
event.preventDefault();
$j("#box").slideToggle();
});
});
Basically anywhere you would have used just the $ sign you add in a “j”. The variable name can be anything some examples use $js I just chose $j.
Please sign up for my feed as I will be adding more wordpress and jQuery goodness!
It took me several failed jquery projects before I got a handle on how to get it working conflict free in WordPress. I wish I had found this tip sooner.
.-= donnie´s last blog ..SEO TIP- Goodbye PageRank- Hello Trust and Authority =-.
Thanks for the tip, using noconflict sounds simple enough.
Thanks Michael. Hopefully this will save you some debugging time.