Show hide / show menu

1

I'm having a question I'm using Wordpress This is my jquery to get the link that I am clicking and through an anchor ID # it scrolls down to the desired content but I need to hide everything and when clicking only appears the content clicked.

$('.sub-menu a').click(function() {
    var anchor;
    var link = $(this).attr('href');
    if (link.indexOf('#') !== -1) {
        anchor = '#' + link.split('#').pop();
    }

    if (anchor !== undefined) { 
        show().$(anchor) 
        $('html, body').animate({scrollTop: $(anchor).offset().top}, 2000);
    }

});
    
asked by anonymous 18.07.2018 / 17:17

1 answer

0
 $('.sub-menu a').click(function() {
    var anchor;
    var link = $(this).attr('href');
    if (link.indexOf('#') !== -1) {
        anchor = '#' + link.split('#').pop();
    }
    $('.id-sub').slideUp("slow");
     if (anchor !== undefined) {
        $(anchor).slideDown("slow").addClass('#sobre');


     }

});
    
18.07.2018 / 21:37