Javascript 左右滑动控件时,推特引导旋转木马不断向上移动

Javascript 左右滑动控件时,推特引导旋转木马不断向上移动,javascript,jquery,css,twitter-bootstrap,twitter-bootstrap-3,Javascript,Jquery,Css,Twitter Bootstrap,Twitter Bootstrap 3,每次导航/滑动控件到左侧或右侧时,我的bootstrap 3.3 carousel(代码直接取自getbootstrap.com)都会一直向上移动到浏览器顶部 如果旋转木马在页面的中间,你开始手动滑动,它将整个页面移动,直到旋转木马击中浏览器顶部。 示例如下: 如何更正此问题?这是导致web向上滚动的代码: $('a[href*=#]').each(function() { var thisPath = filterPath(this.pathname) || locationPath; if

每次导航/滑动控件到左侧或右侧时,我的bootstrap 3.3 carousel(代码直接取自getbootstrap.com)都会一直向上移动到浏览器顶部

如果旋转木马在页面的中间,你开始手动滑动,它将整个页面移动,直到旋转木马击中浏览器顶部。

示例如下:


如何更正此问题?

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

$('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;
      });
    });
  }
}
$('a[href*=#]')。每个(函数(){
var thisPath=filterPath(this.pathname)| | locationPath;
如果(locationPath==此路径
&&(location.hostname==this.hostname | |!this.hostname)
&&this.hash.replace(/#/,''){
var$target=$(this.hash),target=this.hash;
如果(目标){
var targetOffset=$target.offset().top;
$(此)。单击(函数(事件){
event.preventDefault();
$(scrollElem).animate({scrollTop:targetOffset},800,function(){/
href=“#carousel branding project”
在旋转木马的HTML定义中导致页面链接到旋转木马的父div
id=“carousel branding project”

如果需要将其作为锚定,请尝试将链接更改为
href=“javascript:void(0)”



但我正在将图像加载到幻灯片中,因为它需要响应并且应该按比例缩放,所以我无法定义固定的高度。所有图像都有相同的大小,因此高度是给定/固定的。@rainerbrunotte很抱歉,我帮不上什么忙,如果没有这个问题的实例,我很难理解-可能会有对于您的问题,有多种解决方案,但是没有示例就太模糊了。我添加了上面的示例链接,谢谢!您会看到,当您在页面上一直向上滚动,然后使用旋转木马滑块向左向右导航时,整个旋转木马将向上移动,直到它碰到浏览器top@rainerbrunotte-我已经更新了我的答案-希望如此将帮助你真棒!它有效!这就是问题所在!我不知道为什么我将它链接到每个A元素,我只是在我的网站上为另一个滚动条获取了代码,但没有注意到它实际上也影响了其他A链接!哈哈!谢谢你!)谢谢!但是它不起作用…我直接从这里获取了原始代码:,而在那里它不会向上移动…它必须是您在页面上的其他脚本之一中的某个内容。尝试使用复制问题所需的最少代码创建一个JSFIDLE,以便我们可以隔离它。是的,实际上是这样,我有另一个JS脚本我的网站的另一部分把它搞砸了,请看上面!谢谢你的帮助!
  <a class="left carousel-control" href="javascript:void(0)"role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
  </a>
  <a class="right carousel-control" href="javascript:void(0)" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>
  </a>