Javascript jQuery滚动偏移量

时间:2020-05-02 12:53:24

标签: javascript jquery scroll offset

我要在滚动并偏移> 600和<1200后更改页面。我尝试过if ($('html').scrollTop() >= 600 && $('html').scrollTop() <= 1260),但是它只能工作一次。怎么能持续?

1 个答案:

答案 0 :(得分:0)

要滚动更新,您将要使用事件监听器。具体来说,是jQuery中的scroll侦听器。

$(document).scroll(function(){
  // conditional here.
});

您可以在此处查看jQuery事件的列表-https://api.jquery.com/category/events/