$ Instead of jQuery in WordPress – WP jQuery

$ is not working in your WordPress? Try simple method and use $ instead of jQuery in wordpress theme. Enclose dollar sign in bracket of function in jQuery.

While using MooTools or prototype ($) sign conflicts with jQuery library. For the sake of compatibility mode developers choose safe way and use jQuery instead of $ sign. jQuery provide compatibility mode by default to work safely like jQuery.noConflict() to avoid conflict errors. Learn how to use $ sign instead of  jQuery keyword in wordpress.

WordPress developers use jQuery keyword to avoid future conflicts of $. Learn to manage $ sign instead of jQuery.

Normal Way to Use jQuery:

/* jQuery we use in HTML basic */

/* WordPress "Safe" jQuery way */


Writing jQuery keyword hundreds makes life harder to debug errors as well as bloats the file size. Usually developers load scripts in footer (major cases load jquery in last). Wrap your code in anonymous function (technically any IIFE). Mapped your jQuery keyword to $ sign. where you pass in jQuery to be mapped to $.

(function($) {

// $ Works! You can test it with next line if you like
 $("div").text('twoclock'); \\ $ starts working now

})( jQuery );

Probably you wants to load scripts jQuery to header. Use document ready function, pass $ in brackets. By default document ready loaded in header according to jQuery even if you write document ready scripts in footer.

jQuery(document).ready(function( $ ) {
// $ Works! You can test it with next line if you like
 $("div").text('$ is start working'); \\ it will work now



Leave a Reply

Your email address will not be published. Required fields are marked *