Jquery after Reload

Asked

Viewed 58 times

0

I wonder if there’s any way to do it, because I have a function that when I click on a menu button it captures via jquery the id of the page but if example I am on the START page that has no id and go to page service that has ID it gives a Reload and my action does not work have some way pebble storage us coookies sap ?

 $('.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 next I need to hide all the contents in the class ('.id-sub') more when I left the page START and click on the page SERVICE he had to show me only the ID 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 I clicked

  • Specify what you want to do, i.e., what functionality you want to implode.

  • so I have a menu that contains INICIO and SERVIÇOS (com sub-menus) each sub-menus of these has a certain ID when I am on the START page and I want to go to the SERVICE page it has to see the id I clicked that the above function already shows the correct id and hide the others because if this content is on a single page

  • if I am already inside the page SERVIÇO and click on id it works normally but when I’m on the page INICIO and click on a sub-menu it shows all the content of that page being that it was to show only the content of id clicked

  • gave to understand a little?

  • I’m sorry but I can’t understand the purpose

  • have a MENU this menu has INICIO and SERVIÇO (com sub-menus de cada serviço) if I am on the menu page and click on the sub-menus it gives a sliderUP and slideDown effect as per the id that is clicked from the sub-menu but if I am on the page INICIO and click on a id of the sub-menu it would have to show only the content of the id that I clicked right more it doesn’t happen it just from Reload on the page and shows all contents of all id

  • what I want to do is to change the page it shows me only the content of id clicked

Show 2 more comments

1 answer

0


I managed to solve my problem thanks..

//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 });
            }
        });


    });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.