Wednesday, 21 August 2013

Twitter bootstrap carousel does not auto start

Twitter bootstrap carousel does not auto start

I know that this question has been asked earlier, however the solution
there did not work for me.
My code:
<div id="gallerycontainer">
<div class="carousel-inner" align="center" style="margin-top:10px;">
<div class="item active" style="border:5px solid black;"><!-- class of
active since it's the first item -->
<img src="bootstrap/img/slider5.jpg" height="400px" alt="" />
<div class="carousel-caption">
<p>Caption text here</p>
</div>
</div>
<div class="item" style="border:5px solid black;">
<img src="http://placehold.it/1200x480" alt="" />
<div class="carousel-caption">
<p>Caption text here</p>
</div>
</div>
<div class="item" style="border:5px solid black;">
<img src="bootstrap/img/slider3.jpg" height="400px" width="960px" alt="" />
<div class="carousel-caption">
<p>Caption text here</p>
</div>
</div>
<div class="item" style="border:5px solid black;">
<img src="bootstrap/img/slider4.jpg" height="400px" width="960px" alt="" />
<div class="carousel-caption">
<p>Our bedrooms are spacious and extremely luxurious.</p>
</div>
</div>
`
gallerycontainer is a self created div within which my carousel is placed.
I've called the function in the head by using this:
<script type="text/javascript">
$(document).ready(function(){
$('.carousel').carousel({interval: 2000});
});
</script>
My problem is, the auto slide starts only after I click the next button at
least once. What am I doing wrong?

No comments:

Post a Comment