I have a pair of indicator lists for a bootstrap carousel
First List:
<ol class="rightci carousel-indicators">
<li class="active" data-target="#carousel-example-generic" data-slide-to="0" ></li>
<li data-target="#carousel-example-generic" data-slide-to="1" ></li>
<li data-target="#carousel-example-generic" data-slide-to="2" ></li>
<li data-target="#carousel-example-generic" data-slide-to="3" ></li>
</ol>
Second List:
<div class="left leftci carousel-indicators">
<a href=""><span class="leftindicators" data-target="#carousel-example-generic" data-slide-to="0">slide1</span></a>
<a href=""><span class="leftindicators" data-target="#carousel-example-generic" data-slide-to="1">slide2</span></a>
<a href=""><span class="leftindicators" data-target="#carousel-example-generic" data-slide-to="2">slide3</span></a>
<a href=""><span class="leftindicators" data-target="#carousel-example-generic" data-slide-to="3">slide4</span></a>
</div>
The goal is to check if the children of the First list have the active
class and then add the active
class to the corresponding children in the Second list.
Since the First list serves as the carousel indicators, it changes as the carousel item
changes.
For Example:
If the third item from the First list has the active
class, then add the active
class to the third item of the Second list.
This is the jQuery code I tried (I am new to jQuery):
var index = $('#rcl li.active').parent().index();
$('#lcl span.activelink').removeClass('activelink');
$('#lcl span').eq(index).addClass('activelink');
I'm currently experimenting with this concept. Check out the example on both indicators here: https://jsfiddle.net/ppwn8oau/