Possible conflicting jquery libraries

百般思念 提交于 2019-12-12 03:18:12

问题


I'm using the 'reveal modal' which is working fine with the jquery-1.4.4. library however since adding the library the 'pop-up' menu for the mobile version of the site has stopped working. I removed the jquery-1.4.4. library and the 'pop-up'menu started working again but the modal stopped so I assume there is something conflicting with that library.

I have tried a piece of script that allows multiple jquery libraries without conflict but it didn't seem to work so I'm thinking the easiest way is to maybe re-wrtie the code for the 'pop-up- menu in a way that doesnt conflict but i'm not sure how.

The code I'm using for the pop-up' menu is as follows. (the menu only shows up on mobile size so you may have to decrease the width of your browser)

$(function() {
        var pull        = $('.pull');
            menu        = $('.navigation ul');
            menuHeight  = menu.height();

        $(pull).on('click', function(e) {
            e.preventDefault();
            menu.slideToggle();
        });


        $(window).resize(function(){
            var w = $(window).width();
            if(w > 320 && menu.is(':hidden')) {
                menu.removeAttr('style');
            }
        });
    });

The reveal modal is attached to the question mark button on the index page and the url is mike-griffin.com/index.html (the question mark button is on the desktop size site so browser width will need to be above 481px.


回答1:


Using the following should solve your issue:

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script>
        //code that uses 1.10.2 should be enclosed as follows right after loading 1.10.2
        jQuery(function( $ ) {
            //1.10.2 code goes here
        });
    </script>
    <script src="js/jquery-1.4.4.min.js"></script>
    <script>
        //code that uses 1.4.4 should be enclosed as follows
        jQuery(function( $ ) {
            //1.4.4 code goes here
        });
    </script>


来源:https://stackoverflow.com/questions/26878464/possible-conflicting-jquery-libraries

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