noConflict() Method - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:noConflict

Description

The noConflict() method releases jQuery's control of the $ variable.

Syntax

Parameter Require Data Type Description
removeAll Optional.Boolean value whether to release jQuery's control of ALL jQuery variables (including "jQuery")

The following code shows how to Use the noConflict() method to specify a new name for the jQuery variable:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
var jq = $.noConflict();//from w  w  w.j a  va2  s.c  o m
jq(document).ready(function(){
    jq("button").click(function(){
        jq("p").hide();
    });
});
</script>
</head>
<body>

<h2>This is a heading</h2>

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

<button>Click me</button>

</body>
</html>

Related Tutorials