Home  >  Article  >  Backend Development  >  javascript - Introduce 2 js. A waterfall and a pop-up window. Conflict on $ sign

javascript - Introduce 2 js. A waterfall and a pop-up window. Conflict on $ sign

WBOY
WBOYOriginal
2016-08-29 08:50:49933browse

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>

Reply content:

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 $

was found in the document demo of

baguettebox

So, what caused the conflict? 🎜
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn