You can of course still use jQuery, simply by writing the full name instead of the shortcut:
Example(1)
<script> $.noConflict(); jQuery(document).ready(function(){ jQuery("button").click(function(){ jQuery("p").text("jQuery is still working!"); }); }); </script>
noConflict()
method returns a reference to jQuery, that you can save in a variable, for later use. Here is an example:<script> var jq = $.noConflict(); jq(document).ready(function(){ jq("button").click(function(){ jq("p").text("jQuery is still working!"); }); }); </script>
$
shortcut and you do not want to change it all, you can pass the $
sign in as a parameter to the ready method. This allows you to access jQuery using $
, inside this function - outside of it, you will have to use "jQuery":$.noConflict(); jQuery(document).ready(function($){ $("button").click(function(){ $("p").text("jQuery is still working!"); }); });
<!DOCTYPE html> <html> <head> <title>How To Use NoConflict Method In JQuery With Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <style> body { background: black; } </style> <body> <div class="container"> <br><br><br><br> <div class="text-center"> <h2 id="color" style="color: White;">NoConflict Method In JQuery</h2> </div> <br> <div class="well"> <h2>This is a paragraph.</h2> <button class="btn btn-info">Test jQuery</button> </div> </div> </body> </html> <script> $.noConflict(); jQuery(document).ready(function($){ $("button").click(function(){ $("h2").text("jQuery is still working!"); }); }); </script>