When a project introduces multiple third-party libraries, the conflict between the library and the repository is unavoidable because there is no namespace constraint (the namespace is like a folder in the same directory, the same name causes a conflict).
Since there is a conflict problem, why apply multiple libraries? Because jquery is just a DOM-based library that facilitates our daily web development, but sometimes our projects may need to apply other libraries to solve special problems. such as UI libraries, game libraries, and so on.
For example, the prototype library, and so on, or a library of its own definition using the $ symbol, how to solve it? For example, we have a base library that we have developed ourselves, and we also use the $ symbol, and in general there are two ways to solve it.
1, the jquery library is referenced before the base library, then the ownership of "$" is given to the base library, and jquery can be invoked directly using jquery objects, or create a "$$" for jquery.
Suppose our base library has a GE () method var $$ = jquery;$ (function () {Alert ($ ("#box"). GE (0)); Alert ($$ ("#box"). width ());})
2. If the jquery library is referenced after the base library, then the "$" ownership is owned by jquery, and the base library will lose its role because of the conflict, where jquery provides a way
Jquery.noconflict (); Self-destruct, the $ ownership culling var $$ = jquery;$ (function () {alert ("#box"). GE (0)); Alert ($$ ("#box"). width ());})
This article is from the "Unruly Wind" blog, please be sure to keep this source http://fengcl.blog.51cto.com/9961331/1875984
Solution to the $ symbol conflict problem when using jquery