简体   繁体   English

chrome上的ScrollTop Bug jQuery

[英]ScrollTop bug jquery On chrome

In my website I made sticky header. 在我的网站上,我设置了粘性标头。

It works very well on every browsers but when I test on a Macbook on Chrome there's a bug with the scrollTop 它在所有浏览器上都能很好地工作,但是当我在Chrome上的Macbook上进行测试时, scrollTop出现了一个错误

I've my main header and a sticky header : 我有主标题和粘性标题:

I code this : 我写这个:

$(document).on('scroll',function() {    
    if ($(document).scrollTop() >= 150) {
        $('header:not(.sticky)').hide();
        $('header.sticky').show();
    } else {
        $('header:not(.sticky)').show();
        $('header.sticky').hide();
    }
});

When I scroll to 150px it jumps to the top of my page. 当我滚动到150px时,它会跳到页面顶部。

Thanks for your help ! 谢谢你的帮助 !

This works fine in Chrome in Mac Machine 在Mac Machine中的Chrome中正常运行

  $(document).scroll(()=> {
    if($(this).scrollTop()>= 150) {
      //Your Actions 
    }
    else {
      //Your Actions
    }
  });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM