Function on window.scroll and get the vertical offset [duplicate]
问题 This question already has answers here : Trigger event when user scroll to specific element - with jQuery (12 answers) Closed 2 years ago . window.scroll=function MyFunc(){ var y = window.scrollTop(); alert(y); } How to call a function when the window is scrolled and how to get the amount of pixels the window has been vertically scrolled. I want to play an animation when a desired value has been reached. Help. 回答1: You can use window.onscroll without the use of jQuery . That was what you were