How to AUTO SCROLL an output on web | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to AUTO SCROLL an output on web

lets say I have <div style="overflow-y:scroll"></div> I need to scroll it automatically when there is new text to show

4th Dec 2017, 12:45 AM
Nura Programmer
Nura Programmer - avatar
3 Answers
+ 6
try using scrollTop... example: container=document.getElementById("container"); container.scrollTop =container. scrollHeight; hope this help....
4th Dec 2017, 3:02 AM
Leon lit
Leon lit - avatar
+ 2
Use document.body.scrollTop = wrap.scrollHeight; where wrap is a updating scrollable element. Check out the code https://code.sololearn.com/Wpel83cdJbol/?ref=app
4th Dec 2017, 6:20 AM
Calviղ
Calviղ - avatar
+ 1
Thank you @leon or by the way I am happy to have this answered
5th Dec 2017, 11:46 PM
Nura Programmer
Nura Programmer - avatar