Trigger events when the window is scrolled to certain positions

后端 未结 4 1189
别那么骄傲
别那么骄傲 2020-12-01 10:11

I would like to call functions when the browser window goes beyond a certain point
(e.g the user scrolled the window down beyond 200px from the top

Is there an e

4条回答
  •  清歌不尽
    2020-12-01 10:11

    You can use onscroll

    function testScroll(ev){
        if(window.pageYOffset>400)alert('User has scrolled at least 400 px!');
    }
    window.onscroll=testScroll
    

    If you want a jQuery solution you can use scroll.

提交回复
热议问题