kob003

Sign in

pic: Designed by user2104819 / Freepik

Properties to be discussed:

ScrollY & pageYOffset:

scrollTop:

scrollHeight:

Properties’ horizontal counterpart:

Functions to scroll:

1. scrollTo(), 2.scrollBy();

1. ScrollTo():

If we want to scroll a particular element:

element.scrollTo(x-coord, y-coord)

If we want to scroll the whole window:

window.scrollTo(x-coord, y-coord)

2. ScrollBy():

If we want to scroll a particular element:

element.scrollBy(x-coord, y-coord)

If we want to scroll the whole window:

window.scrollBy(x-coord, y-coord)

an apprentice