Capturing the “scroll down” event?

后端 未结 10 2231
闹比i
闹比i 2020-12-28 12:17

I\'m designing a very simple web page (HTML only), the only \"feature\" I want to implement is to do something when the user scrolls down the page, is there a way to capture

10条回答
  •  难免孤独
    2020-12-28 12:57

    This works for me.

    var previousPosition
    
    $(window).scroll(function(){
      var currentScrollPosition=$(window).scrollTop() + $(window).height()
      if (currentScrollPosition>previousScrollPosition) {
        console.log('down')
      }else if(currentScrollPosition

提交回复
热议问题