twitter-bootstrap Bootstrap 轮播忽略数据间隔属性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20873278/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 19:37:46  来源:igfitidea点击:

Bootstrap carousel ignoring data-interval attribute

javascriptjquerycsstwitter-bootstraptwitter-bootstrap-3

提问by codedog

Here's my markup:

这是我的标记:

<div id="carousel-example-generic" class="carousel slide" data-interval="false" data-pause="hover">
        <!-- Indicators -->
        <ol class="carousel-indicators">
            <li data-target="#carousel-example-generic" data-slide-to="0"></li>
            <li data-target="#carousel-example-generic" data-slide-to="1"></li>
            <li data-target="#carousel-example-generic" data-slide-to="2"></li>
        </ol>

        <!-- Wrapper for slides -->
        <div class="carousel-inner">
            <div class="item active">
                <div style="height:200px;">Slide 1</div>
                <div class="carousel-caption">
                    ...
                </div>
            </div>
            <div class="item">
                <div style="height:200px;">Slide 2</div>
                <div class="carousel-caption">
                    ...
                </div>
            </div>
            <div class="item ">
                <div style="height:200px;">Slide 3</div>
                <div class="carousel-caption">
                    ...
                </div>
            </div>
        </div>

        <!-- Controls -->
        <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left"></span>
        </a>
        <a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right"></span>
        </a>
    </div>

I am using bootstrap v3.0.3, and yet the carousel still starts scrolling after page is loaded. I have also tried including:

我使用的是 bootstrap v3.0.3,但在页面加载后轮播仍然开始滚动。我也试过包括:

$(function () {
    $(".carousel").carousel({ interval: false });
});

I've done this with and without the data-intervalattribute, all to no avail. The carousel automatically starts scrolling after page is loaded. I have seen other questions about this but they were all referring to older version and implied it has been fixed by now.

我在有和没有data-interval属性的情况下都这样做了,但都无济于事。加载页面后,轮播自动开始滚动。我已经看到有关此的其他问题,但他们都指的是旧版本,并暗示它现在已经修复。

Any ideas please?

请问有什么想法吗?

采纳答案by Zim

Your carousel markup is correct for 3.0.3 (http://bootply.com/103352)

您的轮播标记适用于 3.0.3 ( http://bootply.com/103352)

Make sure there is not other JavaScript code or other carousels on the same page.

确保同一页面上没有其他 JavaScript 代码或其他轮播。