Using “jQuery” instead of “$” in WordPress

In jQuery, the dollar sign character ($) is a shortcut used to represent “jQuery”. You can start your expressions like this:

$('.content').css('color','red');

But, other JS libraries and frameworks also use this character, so with WordPress you must use “JQuery” instead of “$”.

jQuery('.content').css('color','red');

There is a workaround where you can wrap the code in an anonymous function and still use “$”.

(function($) {
	
  $('.content').css('color','red');
	
})( jQuery );

read more…

digwp.com/2011/09/using-instead-of-jquery-in-wordpress

Thank you for reading!

It's only fair to share...Tweet about this on Twitter
Twitter
Share on Facebook
Facebook
Email this to someone
email
This entry was posted in jQuery, WordPress and tagged , . Bookmark the permalink.