Basically what I am trying to do is, I have one Bootstrap carousel with 8 slides in it.I am using 2 carousel-indicators.
This is my first indicator it work fine with .active
class
<ol class="rightci carousel-indicators"> <li data-target="#carousel-example-generic" data-slide-to="0" ></li> </ol>
this is my Second Indicator it works fine.when I click on the link carousel slides change perfectly but .active
class dose not change automatically rather on first indicators .active
changes fine.
<div class="left leftci carousel-indicators"> <a href=""><span class="leftindicators active" data-target="#carousel-example-generic" data-slide-to="0">slide1</span></a> </div>
help me with it
Advertisement
Answer
I think you need to write some custom js Bootstrap has not this functionality by default so you need to make your own carousel-indicators
css
.carousel-indicators2 { position: absolute; top: 10px; left: 50%; z-index: 15; width: 60%; padding-left: 0; margin-left: -30%; text-align: center; list-style: none; } .carousel-indicators2 li { display: inline-block; width: 10px; height: 10px; margin: 1px; text-indent: -999px; cursor: pointer; background-color: #0009; background-color: rgba(0, 0, 0, 0); border: 1px solid #fff; border-radius: 10px; } .carousel-indicators2 .active { width: 12px; height: 12px; margin: 0; background-color: #fff; }
JS
$('.carousel').on('slid.bs.carousel', function() { $(".carousel-indicators2 li").removeClass("active"); indicators = $(".carousel-indicators li.active").data("slide-to"); a = $(".carousel-indicators2").find("[data-slide-to='" + indicators + "']").addClass("active"); console.log(indicators); })