- UPDATE-- 我找到了解决方案,暂停对我不起作用,但我发现如果你添加: interval:false 它就像我想要的那样工作。谢谢你们:)
我正在使用Bootstrap的3个旋转木马,我一直试图阻止它,以便它不会自动滑动。我一直在使用他们提供的功能。 这就是我所拥有的:
$('.carousel').carousel({
.carousel('pause')
})
我该如何阻止它?
这是HTML,默认来自Bootstrap的示例页面:
<!-- Carousel
================================================== -->
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<iframe width="100%" height="630" src="//www.youtube.com/embed/9vTguAVhjBo" frameborder="0" allowfullscreen></iframe>
<div class="container">
<div class="carousel-caption">
<h1>Example headline.</h1>
<p>Note: If you're viewing this page via a <code>file://</code> URL, the "next" and "previous" Glyphicon buttons on the left and right might not load/display properly due to web browser security rules.</p>
<p><a class="btn btn-lg btn-primary" href="#" role="button">Sign up today</a></p>
</div>
</div>
</div>
<div class="item">
<iframe width="100%" height="630" src="//www.youtube.com/embed/gyV2CSqJi1I" frameborder="0" allowfullscreen></iframe>
<div class="container">
<div class="carousel-caption">
<h1>Another example headline.</h1>
<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<p><a class="btn btn-lg btn-primary" href="#" role="button">Learn more</a></p>
</div>
</div>
</div>
<div class="item">
<iframe width="100%" height="630" src="//www.youtube.com/embed/kYbvYS65iDs" frameborder="0" allowfullscreen></iframe>
<div class="container">
<div class="carousel-caption">
<h1>One more for good measure.</h1>
<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<p><a class="btn btn-lg btn-primary" href="#" role="button">Browse gallery</a></p>
</div>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
<a class="right carousel-control" href="#myCarousel" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
</div><!-- /.carousel -->
答案 0 :(得分:2)
间隔:自动循环播放之间的延迟时间 项目。如果为false,轮播将不会自动循环。
$('.carousel').carousel({
interval: false
})
答案 1 :(得分:1)
相反,请使用此行
$('.carousel').carousel('pause');
答案 2 :(得分:0)
传递attr data-interval
替换
<div id="myCarousel" class="carousel slide" data-ride="carousel">
到
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="false">
diff:data-interval =&#34; false&#34;