Hide menu, show Sticky

Asked

Viewed 21 times

-1

I am making a site in wordpress, but my problem is that, I want to hide the menu by default and make appear only the Sticky menu.

How can I do this with javascript? I’ve tried and searched, but I can never get to the desired result, I can’t hide the original menu and show only Sticky.

jQuery(document).scroll(function($) {
  if (jquery('#mysticky-nav').hasClass('up')) {
    jQuery('#mysticky-nav').css("opacity", "0");
  } else {
    jQuery('#mysticky-nav').css("opacity", "1");
  }
});

1 answer

0

Not understood very well, you want to display/hide the menu at the time of page loading or when to scroll the screen? 'Cause if it’s in the shipment, it could be something like this:

window.onload = function escondeMenu() { 

     let menu = document.querySelector('#IdDoMenu'); // INSIRA AQUI O #id ou .class DO MENU QUE VOCÊ QUER ESCONDER NO LUGAR DO PARÂMETRO PASSADO NO 'querySelector'
     let sticky = document.querySelector('#mysticky-nav');

     menu.setAttribute('style', 'display: none !important;');
     sticky.setAttribute('style', 'display: block !important;');
}

I hope I’ve helped.

Browser other questions tagged

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