JQuery Slideshow and MooTools Conflict

有些话、适合烂在心里 提交于 2019-12-02 08:49:15

Once you call jQuery.noConflict(), you refer to jQuery via jQuery rather than $. $ is then usable by MooTools or another JavaScript library.

<script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(function() {
        jQuery(window).load(function () {
                // start the slideshow
                jQuery('.slideshow').blinds();
        })
    });
</script>

If you want to give jQuery another name, you can do the following:

<script type="text/javascript">
    var jq = jQuery.noConflict();
    jq(document).ready(function() {
        jq(window).load(function () {
                // start the slideshow
                jq('.slideshow').blinds();
        })
    });
</script>

You want jQuery.noConflict().

But you don't really need to, because you are using jQuery for your jQuery alias, and you are passing $ as the argument which maps to the jQuery object.

So long as all your jQuery (and jQuery only) happens inside that jQuery(document).ready(), then you can use $ for jQuery and not worry about about clashes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!