Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

64
Visualizações
Issue with button not working when scrolling up

I have a hamburger button that sticks to the top right corner of the page as you scroll down the page. When clicked, the hamburger button displays a nav menu. However, if I scroll up on the page the hamburger button functionality does not work. In my code, the hamburger button is named "menuBtn" and the sticky class that is added in the code just makes the position of the button fixed. I have attached my JavaScript code because I believe this is the problem.

const hamburgerMenu = document.querySelector('.hamburger__anchors--bin');
const menuBtn = document.querySelector('.menu-btn');
//sticky hamburger btn 
window.onscroll = function() {
    if(window.pageYOffset >= menuBtn.offsetTop) {
        menuBtn.classList.add('sticky')
        hamburgerMenu.classList.toggle('stickytwo');
    } else {
        menuBtn.classList.remove('sticky')

    }
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda