简体   繁体   中英

jQuery scripts don't want to work together

I am making a website. I am doing responsive menu and jQuery script work but not good. I mean that every single script wokrs very well but all of them together don't want to work that good. The first one, this from responsive menu is killing every thing, so this menu is not working as it should be :/

<script type="text/javascript" src="jquery-2.2.3.min.js"></script>

<script type="text/javascript" src="jquery.scrollTo.min.js"></script>

<script type="text/javascript" src="jquery.sticky.js"></script>

<script>

    $(document).ready(function(){
        $(".menu-trigger").click(function(){
            $("#mainnav").slideToggle(900);
        });
    });

    jQuery(function($)
    {
        //zresetuj scrolla
        $.scrollTo(0);

        $('#link').click(function() { $.scrollTo($('#zjazd'), 2000); });
    }
    );

    $(document).ready(function(){

        $("#container").sticky({topSpacing:0});

    });

    $(document).ready(function(){

        $(window).scroll(function(){
            if ($(this).scrollTop() > 400) {
                $('.scrollup').fadeIn('slow');
            } else {
                $('.scrollup').fadeOut('fast');
            }
        });

        //Kliknij aby przewinąć do góry
        $('.scrollup').click(function(){
            $('html, body').animate({scrollTop : 0},1500);
            return false;
        });

    });

</script>

So what is wrong? What is going om? I'm still learning and it can be really silly problem but for today for me...

All website is responsive already.

You can see here what's wrong

When I delete rest of scripts and leave only this for responsive menu it works beautiful, when I delete this for responsive menu then all rest works well, but when all scripts are together then only this for menu works not well but rest of it works normal. I don't know what is going on.

I'm still learning... and the website which I'm working od is pretty good.

You only need one $(document).ready(function() { });

And the first thing inside of it should be calling the plugins you want to use.

$(document).ready(function(){
    $("#container").sticky({topSpacing:0});

    $.scrollTo(0);

    $(".menu-trigger").click(function(){
        $("#mainnav").slideToggle(900);
    });


    $('#link').click(function() { 
        $.scrollTo($('#zjazd'), 2000); 
    });

    $('.scrollup').click(function(){
        $('html, body').animate({scrollTop : 0},1500);
        return false;
    });
});
$(window).scroll(function(){
    if ($(this).scrollTop() > 400) {
        $('.scrollup').fadeIn('slow');
    } else {
        $('.scrollup').fadeOut('fast');
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM