zepto and jquery will conflict when used together. The solution is: 1. Create an html sample file; 2. Reference the jQuery and zepto files in the head tag; 3. Call "$.noConflict() in the head tag );" method, its code is "<script>$.noConflict();</script>"; 4. Replace the $ symbol in jQuery syntax with jQuery to solve the conflict problem.
Operating system for this tutorial: Windows 10 system, jQuery3.6.0 version, Dell G3 computer.
Solution to the conflict between zepto and jquery:
1. Create an html file and reference jQuery:
<!DOCTYPE html> <html> <head> <script src="/jquery/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="js/zepto.min.js"></script> </head> <body> </body> </html>
2. Call the $.noConflict()
method in the head tag:
<script>$.noConflict();</script>
3. When using jQuery’s $ symbol, replace it with jQuery:
jQuery(document).ready(function(xxx) {// 这里是使用 jQuery $ 的代码 }
The above is the detailed content of Will zepto conflict with jquery if used together?. For more information, please follow other related articles on the PHP Chinese website!