How to avoid Conflict in jQuery

Many JavaScript libraries use $ as a function or variable name, just as jQuery does. In jQuery’s case, $ is just an alias for jQuery, so all functionality is available without using $. If we need to use another JavaScript library alongside jQuery, we can return control of $ back to the other library with a call to $.noConflict():

Creates a different alias instead of jQuery to use in the rest of the script.

var $j = jQuery.noConflict();
// Do something with jQuery
$j("div p").hide();

// Do something with another library's $()
$("content").style.display = 'none';

Permanent link to this article: https://blog.openshell.in/2010/12/how-to-avoid-conflict-in-jquery/

Leave a Reply

Your email address will not be published.