javascript get scroll position 1

javascript get scroll position

function getYPosition(){
  var top  = window.pageYOffset || document.documentElement.scrollTop
  return top;
}

Here is what the above code is Doing:
1. We’re creating a function called getYPosition()
2. We’re using the window.pageYOffset property to get the current vertical position of the scroll bar
3. We’re returning the value of the current vertical position of the scroll bar

Similar Posts