I want to scroll down with my selected document. Tried the below code.
window.scrollTo(x, y);
const body = document.getElementsByClassName("body")[0];
body.scrollTo(x, y);
But, sometimes returns "undefined".
Edit 1: I got the solution. Provided the snippet below that helped me.
- To scroll hole page:
window.scrollTo(x, y)
- To scroll selected div (it should have a long area in order to be able to scrolled down):
document.getElementsByClassName("body")[0].scrollTo(x, y)