How to Fix jQuery Scripts for WordPress

Posted on 22. Jan, 2010 by Jeremy Reis in Website

WordPress uses the Prototype JavaScript library extensively throughout the core, so if you are implementing jQuery scripts you may be frustrated when they do not run, produce errors, or just don’t seem to work. The key is to replace the $ in your jQuery script with the word jQuery, for example, this code hides a paragraph:

$("div.contentToChange p.thirdparagraph").hide("slow");

If you placed that code into a WordPress page, it wouldn’t do anything. Instead, change the $ to jQuery, as in:

jQuery("div.contentToChange p.thirdparagraph").hide("slow");

Now, this code will properly function.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • LinkedIn
  • Ping.fm
  • Propeller
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Tags: , , , ,

Submit a Tip »

Leave a reply