Today, when i try to create a Wordpress plugin with some jQuery effects, and find out the jQuery is not working properly in Wordpress?

Since Wordpress version 2.x, jQuery is a build-in Javascript library, explicitly include the jQuery library into Wordpress is not necessary.

Problem

jQuery is not working in Wordpress plugin writing?

When you try to test a simple jQuery effect like following

$(document).ready(function(){
  alert('test');
});

It’s just not working, no alert message box pop up. When i copy this example to a simple HTML file, it working as expected. What’s the heck? Is there any interoperability issues between jQuery and Wordpress?

After googling about jQuery and Wordpress, i started to understand the reason behind it. In Wordpress, $() is reserved for the Prototype library usage, we should use jQuery() to accomplish any jQuery task.

I made some changes …

jQuery(document).ready(function(){
  alert('test');
});

Alternative you can use noConflict() …

$j=jQuery.noConflict();
 
// Use jQuery via $j(...)
$j(document).ready(function(){
  alert('test');
});

Please visit here for more detail about jQuery.noConflict();
http://wordpress.org/support/topic/141394

Solution

Never use jQuery handy function $() in Wordpress plugin writing. You have to use jQuery() or jQuery.noConflict() to work between jQuery and Wordpress.