admin管理员组文章数量:1130741
I'm using Bootstrap Carousel. All I want is that the slider will only slide when a navigation or a pagination is clicked. I've tried removing
$('.carousel').carousel({
interval: 6000
});
It works fine but my problem is once I've already clicked a navigation or pagination, it is now auto sliding. Is it possible to remove the auto sliding function? If so, how?
I'm using Bootstrap Carousel. All I want is that the slider will only slide when a navigation or a pagination is clicked. I've tried removing
$('.carousel').carousel({
interval: 6000
});
It works fine but my problem is once I've already clicked a navigation or pagination, it is now auto sliding. Is it possible to remove the auto sliding function? If so, how?
Share Improve this question edited Nov 15, 2015 at 9:13 Marged 11k13 gold badges62 silver badges106 bronze badges asked Feb 20, 2013 at 10:20 khatziekhatzie 2,5594 gold badges23 silver badges37 bronze badges10 Answers
Reset to default 300You can do this 2 ways, via js or html (easist)
- Via js
$('.carousel').carousel({
interval: false,
});
That will make the auto sliding stop because there no Milliseconds added and will never slider next.
- Via Html By adding
data-interval="false"
and removingdata-ride="carousel"
<div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel">
becomes:
<div id="carouselExampleCaptions" class="carousel slide" data-interval="false">
updated based on @webMan's comment
From the official docs:
interval The amount of time to delay between automatically cycling an item. If false, carousel will not automatically cycle.
You can either pass this value with javascript or using a data-interval="false"
attribute.
You just need to add one more attribute to your DIV tag which is
data-interval="false"
no need to touch JS!
Change/Add to data-interval="false" on carousel div
<div class="carousel slide" data-ride="carousel" data-type="multi" data-interval="false" id="myCarousel">
In Bootstrap v5 use: data-bs-interval="false"
<div id="carouselExampleCaptions" class="carousel" data-bs-ride="carousel" data-bs-interval="false">
Please try the following:
<script>
$(document).ready(function() {
$('.carousel').carousel('pause');
});
</script>
data-interval="false"
Add this to the corresponding div ...
$(document).ready(function() {
$('#media').carousel({
pause: true,
interval: 40000,
});
});
By using the above script, you will be able to move the images automaticaly
$(document).ready(function() {
$('#media').carousel({
pause: true,
interval: false,
});
});
By using the above script, auto-rotation
will be blocked because interval
is false
for bootstrap 5 just write this data-bs-ride="carousel"
Omitting the data-bs-ride may work.
本文标签: javascriptBootstrap CarouselRemove auto slideStack Overflow
版权声明:本文标题:javascript - Bootstrap Carousel : Remove auto slide - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736742121a1950569.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论