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

Jquery 如何修改jscript以防止某个特定链接滚动?,jquery,twitter-bootstrap,Jquery,Twitter Bootstrap,我使用此代码在页面内滚动。基本上检查内部链接,如果它们是间隔的,则添加平滑滚动: <script> $(function() { $('a[href*=#]:not([href=#])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {

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

<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>

$(函数(){
$('a[href*=#]:非([href=#])。单击(函数(){
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(目标长度){
$('html,body')。设置动画({
scrollTop:target.offset().top
}, 1000);
返回false;
}
}
});
});
然而,我也有一个幻灯片在同一页。这使用了。此代码与幻灯片冲突,我想禁用此
href
的平滑滚动


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

修改选择器以明确排除幻灯片中的任何锚元素。假设幻灯片位于id为
#slideshow
的元素中(作为示例):

虽然我个人认为使用
.not()
方法比使用
:not()
选择器更具可读性(因为语法颜色高亮显示在方法上有效,但不在单个字符串中):


修改选择器以明确排除幻灯片中的任何锚元素。假设幻灯片位于id为
#slideshow
的元素中(作为示例):

虽然我个人认为使用
.not()
方法比使用
:not()
选择器更具可读性(因为语法颜色高亮显示在方法上有效,但不在单个字符串中):


修改选择器以明确排除幻灯片中的任何锚元素。假设幻灯片位于id为
#slideshow
的元素中(作为示例):

虽然我个人认为使用
.not()
方法比使用
:not()
选择器更具可读性(因为语法颜色高亮显示在方法上有效,但不在单个字符串中):


修改选择器以明确排除幻灯片中的任何锚元素。假设幻灯片位于id为
#slideshow
的元素中(作为示例):

虽然我个人认为使用
.not()
方法比使用
:not()
选择器更具可读性(因为语法颜色高亮显示在方法上有效,但不在单个字符串中):

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