22 June 2010
Warning: this article was written over 12 years ago, some information may be out of date.
I found myself having to manage JQuery functions in a WordPress plugin, and the error returned was that of the title:
$ is not a function.
The trick, which worked for me, is replacing all dollar signs $ with jQuery.
Practical example: Let’s say the code I’m using is
$(document).ready(function(){
$("a").click(function(event){
alert("Thanks for your visit!");
});
});
Just change the code like this:
jQuery(document).ready(function(){
jQuery("a").click(function(event){
alert("Thanks for your visit!");
});
});
and everything will work as it should.
Or, as Vinz rightly suggested in the comment below, enter $ as a parameter of function:
jQuery(document).ready(function($){
$("a").click(function(event){
alert("Thanks for your visit!");
});
});