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

102
Views
How do i reset the scroll of a div when you stop hovering over link?

What I am trying to do is when you mouse out over the dropdown menu items the scroll wheel gets reset. I've tried several options that I've been able to find online yet I cant seem to get it to work.

Is there anyone who has an idea on how to do this?

function resetScroll(){
   var scrollPosition = document.getElementsByClassName('list_in_column');
   console.log(scrollPosition);
   scrollPosition.scrollTop = 0;
}

https://jsfiddle.net/Amyttyl/uyh5g7zo/

I've tried the ScrollTop(https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop) and ScrollTo (https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo)functions in jQuery but they don't seem to work for me. I'm only a beginner at jQuery so i don't know what i'm doing wrong.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The display:none that i was using on my menu made it so that scroll to did not work. changing the display:none to opacity: 0 & pointer-events: none; and using this javascript

document.querySelectorAll('.mega-drop-down').forEach(dropdown => {
        dropdown.addEventListener('mouseleave', (element) => {
            dropdown.querySelector('.row').scrollTo({
                top: 0,
                behavior: 'smooth',
            });
        });
    }
);

made it work well as you can see in the following fiddle https://jsfiddle.net/9c7g86w1/

about 4 years ago · Juan Pablo Isaza Report
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!