jQuery: Scroll down page a set increment (in pixels) on click?

前端 未结 6 491
既然无缘
既然无缘 2020-12-07 18:48

I\'m trying to make a page scroll down 150px from the current position when an element is clicked. So lets say you\'re roughly halfway scrolled down a page. You click this

6条回答
  •  旧巷少年郎
    2020-12-07 18:51

    Updated version of HCD's solution which avoids conflict:

    var y = $j(window).scrollTop(); 
    $j("html, body").animate({ scrollTop: y + $j(window).height() }, 600);
    

提交回复
热议问题