In front-end development, $ is a function in jQuery. If the parameters of $ are different, the functions implemented are different. During programming, $, as a symbol, may conflict with defined names in other files. So how do we handle this conflict? This article introduces two methods: 1. Solve the problem by releasing the right to use the $ symbol in the jQuery framework; 2. Solve using custom access symbols. Method 1: Releasing the right to use the $ symbol in the jQuery frameworkProcessing instructions: $ is just an alias of jquery. If you need to use another js library other than jquery, you can return control to the library by calling $.noConflict(). jQuery.noConflict(); jQuery(function () { alert("hellow") }); Note: The release operation must be written before writing other jQuery codes, and after the release, $ cannot be used, use jQuery instead. Method 2: Use custom access symbols to solveProcessing instructions: Customize a nj to replace the function of $ var nj =jQuery.noConflict(); nj(function(){ alert("hello inj custom access symbol") }); This is the end of this article on how to solve the jQuery conflict problem. For more information on how to deal with the jQuery conflict problem, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Nginx proxy forwarding implementation code uploaded by Alibaba Cloud OSS
>>: MySQL 5.7.10 winx64 installation and configuration method graphic tutorial (win10)
Table of contents 1. Shallow copy 1. Object.assig...
This article example shares the specific code of ...
1. What is a proxy server? Proxy server, when the...
In many projects, it is necessary to implement th...
Table of contents Preface: Kind tips: variable 1....
Database migration is a problem we often encounte...
The front-end development department is growing, ...
Preface There are many open source monitoring too...
Table of contents Use Cases Reactive API related ...
The establishment of MySQL index is very importan...
WeChat applet: Simple calculator, for your refere...
Preface This tutorial installs the latest version...
This article example shares the specific code of ...
This article takes the health reporting system of...
Any number of statements can be encapsulated thro...