Jquery after reload

0

I would like to know if there is any way to do it, because I have a function that when I click on a menu button it captures via jquery the page id but if example I am in the HOME page that has no id and is for service page which has id it a reload and my action does not work has some way seila storage in the seila coookies?

 $('.sub-menu a').click(function() {

        var anchor;
        var link = $(this).attr('href');
        if (link.indexOf('#') !== -1) {
            anchor = '#' + link.split('#').pop();
            console.log('anchor',anchor);
        }

        $('.id-sub').slideUp(2000);
        if (anchor !== undefined) {
            $(anchor).slideDown(2000).addClass('fixed');       
            $('html,body').animate({ 'scrollTop': $(anchor) }, 600, function(){
                window.location.hash = target;
            })
        }
    });

Because the next thing I need to hide is all the contents that are in the class ('.id-sub') more when I left the HOME page and click on the SERVICE page it had to show me only the ID that I clicked and hide the rest of the content more like the page of the reload it hides everything and does not show the id that I clicked

    
asked by anonymous 19.07.2018 / 20:46

1 answer

0

I was able to solve my problem thank you ..

//Efeito SliderDown/SliderUp
    $('.sub-menu a').click(function() {

        var anchor;
        var link = $(this).attr('href');
        if (link.indexOf('#') !== -1) {
            anchor = '#' + link.split('#').pop();
            console.log('anchor',anchor);
        }

        $('.id-sub').slideUp(2000);
        if (anchor !== undefined) {
            $(anchor).slideDown(2000).addClass('fixed');       
            $('html,body').animate({ 'scrollTop': $(anchor) }, 600, function(){
                window.location.hash = target;
            })
        }
    });



    //Pre-Loader
    jQuery(window).load(function () {
        $('.id-sub').hide();
        $("#loading").fadeOut(2000,function(){
            $("#page").css("display","block").fadeIn("fast-slow");
            var currentPage = window.location.hash;//
            if (currentPage) {
                $(currentPage).slideDown(2000).addClass('fixed');
                $('html,body').animate({ 'scrollTop': $(currentPage).offset().top });
            }
        });


    });
    
19.07.2018 / 21:20