jQuery and Wordpress: Using noConflict

Justin RainsWelcome! Thank you for visiting!
Please Subscribe to my full feed.

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!

Written on August 18th, 2009 Filed under wordpress

Related Posts:
  • No Related Post

Comments (0)



No Comments »

No comments yet.


RSS feed for comments on this post. TrackBack URI



Leave a comment



CommentLuv Enabled


  • I Share

      Share Feed: Subscribe
  • Recent Visitors

  • Blogroll

  • Cool Stuff