this is my screen shot :
My question is how to make it auto scrolling back to top in javascript or any other way ?
this is my screen shot :
My question is how to make it auto scrolling back to top in javascript or any other way ?
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>
Give an id to your div. And then:
var myDiv = document.getElementById('yourdivid');
myDiv.scrollTop = 0;
If you need to animate, then try the below
$('html, body').animate({scrollTop: '0px'}, 2000);
If its a div you want to animate,
$('#yourid').animate({scrollTop: '0px'}, 1000);