Perfect solution to jQuery symbol $ conflicts with other javascript libraries and frameworks, jqueryjavascript
Currently, there are a large number of javascript development frameworks, some of which use $ as the call symbol, which may lead to conflicts between each other. jQuery solves this problem, you can discard the $ permission when importing jQuery. Then, $ is used by other frameworks. This prevents function calls with the same name from conflict.
JQuery uses the noConflict method to discard the name when calling $, and then uses jQuery to replace $ for writing.
For example:Alert ($ ('# message'). val ());
It must be changed to alert (jQuery ('# message'). val ());
JQuery can run normally.
<Script src = "other_lib.js"> </script> <script src = "jquery. js "> </script> <script> $. noConflict (); // you can only use jQuery to call jQuery ('# message '). val (); </script>
You can also redefine $ for calling.
<script src="other_lib.js"></script><script src="jquery.js"></script><script>$.noConflict();jQuery( document ).ready(function( $ ) { // Code that uses jQuery's $ can follow here.});// Code that uses other library's $ can follow here.</script>
Change to j as the call symbol
var j = jQuery.noConflict(); // Do something with jQueryj( "div p" ).hide(); // Do something with another library's $()$( "content" ).style.display = "none";
The above is a perfect solution to the conflict between jQuery symbol $ and other javascript libraries and frameworks. It is all the content shared by the editor. I hope you can give us a reference and support for more.