Bootstrap carousel slide start without "active"

schani picture schani · Oct 28, 2015 · Viewed 9.2k times · Source

i like to use the Bootstrap carousel slider. Is it possible to start the slider without the active class in the first Image? The code is set with TYPOSCRIPT and i can not set the first item to active. Is there a way with JavaScript?

Thanx for help

Christian

HTML Code

<div class="carousel slide article-slide" id="myCarousel">
    <div class="carousel-inner cont-slider">
        <div class="item">
          <img class="img-responsive" src="http://placehold.it/800x300/cccccc/ffffff">
        </div>
       <div class="item">
          <img class="img-responsive" src="http://placehold.it/800x300/999999/cccccc">
        </div>
        <div class="item">
          <img class="img-responsive" src="http://placehold.it/800x300/dddddd/333333">
        </div>              
    </div>
</div>

Answer

max picture max · Oct 28, 2015

Yes, you can add class like this (using jQuery):

$(document).ready(function () {
  $('#myCarousel').find('.item').first().addClass('active');
});