Javascript examples for jQuery Method and Property:noConflict
The noConflict() method releases jQuery's control of the $ variable.
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:
<!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>