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 ?

Answers 1

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

    var el = document.querySelector('div');
    el.scrollTop = el.scrollHeight;
      el.scrollTop = 0;
    }, 500);
    div{width:200px; height:200px; overflow:auto;}

Related Articles