繁体   English   中英

如何禁用滚动到某些锚点?

[英]How can I disable scrolling to certain anchors?

我已经在网站上添加了锚点滚动,但是由于我在轮播中使用了元素锚,因此每次单击轮播指示器时,页面都会向下滚动一点。

如何禁用那些锚点? 这是我的jQuery:

 $(document).ready(function(){$('a[href^="#"]').on("click",function(a){a.preventDefault(); var b=this.hash,c=$(b); $("html,body").stop().animate({scrollTop:c.offset().top},900,"swing",function(){window.location.hash=b})})}); 

感谢您的帮助。

将它们从选择中删除,而不是。

$('a[href^="#"]').not(".YourCarousel a").on("click", ...

暂无
暂无

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

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