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

285
Views
How to make auto scroll to top of the div?

this is my screen shot :

enter image description here

My question is how to make it auto scrolling back to top in javascript or any other way ?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

element.scrollTop = 0; will let you get to the element's scroll top:

var el = document.querySelector('div');
el.scrollTop = el.scrollHeight;

setTimeout(function(){
  el.scrollTop = 0;
}, 500);
div{width:200px; height:200px; overflow:auto;}
<div>
<br>Top-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-<br>-
</div>

over 4 years ago · Santiago Trujillo Report

0

Please try this:

window.scrollTo(0,0);
over 4 years ago · Santiago Trujillo Report

0

Give an id to your div. And then:

var myDiv = document.getElementById('yourdivid');
myDiv.scrollTop = 0;
over 4 years ago · Santiago Trujillo 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!