jQuery: How to Avoid Conflicting Versions

If you are planning to use jQuery on your web page and there is already another version being used, to prevent any conflict between the two here is what you can do:

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

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

The code above creates a new alias instead of jQuery called j and while the other library is using the $.

Shares