Bootstrap 2 carousel cycle once and then stop

Bootstrap 2 Carousel cycle once and then stop. I suppose I'm a little lost how to do this! Ive tried a loop and an interval, but I just can't find enough documentation on how to make this specific function

Edit --- My code is pretty simple!

<div id="myCarousel" class="carousel slide"><!-- Carousel items -->
<div class="carousel-inner">
<div class="active item"><img src="images/carousel/slide-1.png" /></div>
<div class="item"><img src="images/carousel/slide-2.png" /></div>
<div class="item"><img src="images/carousel/slide-3.png" /></div>
</div>
</div>
<script>
$('#myCarousel').carousel({
        interval: 2500
})
</script>
+1
source share
2 answers

You can do something like this

<script>
   var imgCount = 3;
   $('#myCarousel').carousel({
       interval: 2500
   });
   $('#myCarousel').bind('slid',function(){
      imgCount--;
      if(imgCount == 0)
        $('#myCarousel').carousel('pause');  
   });
</script>
+1
source

Here is an easy way to get what you really need. Just replace the first line of your code with this,

<div id="myCarousel" class="carousel slide" data-wrap="false"><!-- Carousel items -->

And then he should cycle only once. Hope this helps you.

Hooray!!!

+1
source

All Articles