Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

63
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!