向左或向右滑动控件时,Twitter Bootstrap Carousel 不断向上移动

rai*_*tte 5 javascript css jquery twitter-bootstrap twitter-bootstrap-3

每次我使用控件向左或向右导航/滑动时,我的 bootstrap 3.3 轮播(直接从 getbootstrap.com 获取的代码)一直向上移动到浏览器顶部。

因此,如果轮播位于页面中间,并且您开始手动滑动,它会将整个页面向上移动,直到轮播到达浏览器顶部。

这里的例子:http : //crevisio.com/branding/pLXAsNJdn

我该如何纠正?

Alo*_*tan 3

这是导致网页向上滚动的代码:

$('a[href*=#]').each(function() {
var thisPath = filterPath(this.pathname) || locationPath;
if (  locationPath == thisPath
&& (location.hostname == this.hostname || !this.hostname)
&& this.hash.replace(/#/,'') ) {
  var $target = $(this.hash), target = this.hash;
  if (target) {
    var targetOffset = $target.offset().top;
    $(this).click(function(event) {
      event.preventDefault();
      $(scrollElem).animate({scrollTop: targetOffset}, 800, function() { // <== DISABLE THIS AND THE NEXT 2 LINES
        location.hash = target;
      });
    });
  }
}
Run Code Online (Sandbox Code Playgroud)

});

问题是 - 为什么要将 click 事件绑定到每个包含 href 属性的 A 元素#