如何修改jscript以防止某个特定链接滚动?

我正在使用此代码在页面内滚动。 基本上检查内部链接,如果它们是间隔,则添加平滑滚动:

 $(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; } } }); });  

但是,我也在同一页面上播放幻灯片。 这使用Bootstrap的Carousel 。 此代码与幻灯片显示冲突,我想禁用此href平滑滚动。

如何添加代码以防止此冲突?

修改选择器以显式排除幻灯片中的任何锚元素。 假设幻灯片放在id为#slideshow的元素中(作为示例):

 $('a[href*=#]:not([href=#], #slideshow a)').click(function() { 

虽然我个人觉得使用.not()方法而不是:not()选择器更具可读性(因为语法颜色突出显示适用于方法但不适用于单个字符串):

 $('a[href*=#]').not("[href=#], #slideshow a").click(function() {