Try to search your question here, if you can't find : Ask Any Question Now ?

two different .Click() functions working simultaneously and not individually – jquery

HomeCategory: stackoverflowtwo different .Click() functions working simultaneously and not individually – jquery
Avatarkundan asked 4 weeks ago

When clicking the filter tabs, it functions fine but it scrolls the page right at the top. Could anybody please look at the code below what I’m doing wrong in the code.

Whereas Back 2 top function works fine.

I want these two functions to work separately because 1 is image filter and the other scrolls the page back to the top.

    <script>
        $(document).ready(function(){
            $(".button").click(function(){
                var name = $(this).attr("data-filter");
                if(name == "All"){
                    $(".filter").show("2000");
                }
                else{
                    $(".filter").not("."+name).hide("2000");
                    $(".filter").filter("."+name).show("2000");  
                }
            });
            $(".navigation a").click(function(){
                $(this).addClass("active").siblings().removeClass("active");
            });
        });
    </script>
    <script>
        $(window).scroll(function(){
            var height = $(window).scrollTop();
            if(height > 100){
                $("#Back2Top").fadeIn();
            }
            else{
                $("#Back2Top").fadeOut();
            }
        });

        $(document).ready(function(){
            $("#Back2Top").click(function(event){
                event.preventDefault();
                $("html, body").animate({scrollTop:0}, "slow");
                return false;
            });
        });
    </script>

I want both functions to function separately

1 Answers
Best Answer
AvatarJyoti answered 4 weeks ago
Your Answer

2 + 4 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com