如何排除平滑滚动脚本中的链接? (jQuery)
问题描述:
我在我的网站上使用Bootstrap 3传送带。 我也是用这个jQuery脚本:如何排除平滑滚动脚本中的链接? (jQuery)
<script>
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length)
{
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
</script>
的问题是,滑动转盘时,点击#carousel
链接。这使得传送带不起作用。
我想知道的是,是否可以从脚本中排除#carousel
?所以该脚本不适用于#carousel
,但适用于所有其他链接。
谢谢。
答
只需将其添加到选择
$('a[href*=#]:not([href=#]):not([href=#carousel])')
你好。谢谢。我试过这个,但没有奏效。 :-( 编辑:它现在有效,非常感谢。 –
是的,是的..错字。在我看到您的评论之前删除。更多关于报价。 – Shikkediel