Computers & ProgrammingFrontend DevelopmentjQuery

jQuery noConflict Method

There are other JavaScript libraries that use $ as a function or variable name, just as jQuery does. With regard to jQuery, the $ is just an alias for jQuery.

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(). This method can also be used to specify a new custom name for the jQuery variable.


We will use the following HTML for the examples listed below.

<!DOCTYPE html>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
        // ... jQuery Code ...
    <img id="img1" src="go.png" /> ; 
    <div id="div1"> <!-- Some Content --> </div>


removeAllBoolean value indicates whether to remove all jQuery variables from the global scope (including jQuery itself).
var jq=$.noConflict();
        jq("#div1").text("You implemented the noConflict method!");

Leave a Comment

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

Scroll to Top