Home > Article > Backend Development > javascript - Introduce 2 js. A waterfall and a pop-up window. Conflict on $ sign
Introduce 2 js. A waterfall and a pop-up window.
Pop-up
<code><link rel="stylesheet" href="{%$URL%}css/baguettebox.min.css" /> <script src="{%$URL%}js/baguettebox.min.js"></script> </code>
<code> 瀑布流 <script src="{%$URL%}js/jquery-1.8.3.min.js" type="text/javascript"></script> <script src="{%$URL%}js/jaliswall.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $('.wall').jaliswall({ item: '.article' }); }); </script> 这个里面的$ 怎么可以改成既能 被调用 还不会 和 弹窗的js冲突呢? </code>
Introduce 2 js. A waterfall and a pop-up window.
Pop-up
<code><link rel="stylesheet" href="{%$URL%}css/baguettebox.min.css" /> <script src="{%$URL%}js/baguettebox.min.js"></script> </code>
<code> 瀑布流 <script src="{%$URL%}js/jquery-1.8.3.min.js" type="text/javascript"></script> <script src="{%$URL%}js/jaliswall.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $('.wall').jaliswall({ item: '.article' }); }); </script> 这个里面的$ 怎么可以改成既能 被调用 还不会 和 弹窗的js冲突呢? </code>
After introducing jQuery, execute before introducing other libraries:
<code>jQuery.noConflict(); </code>
When you need to use jQuery in the future, for example, change your code to:
<code>jQuery(function () { //.... });</code>
Writing jQuery feels too long and can be changed.
<code>var $$ = jQuery.noConflict();</code>When
is called, it can be written as:
<code>$$(function () { //.... });</code>
jaliswall is originally based on jQuery, which means its $
still represents jQuery
No use of $
baguettebox
So, what caused the conflict? 🎜