Evening
Sorry for the fact that this is probably a really stupid question, I'm still studying!
I am trying to target the active slide in a carousel to complete an action. I would like it to trigger some style changes for each of the three slides, i.e. Changed the colors of buttons, etc.
I used to just try to target divs by their numbers ( #1, #2, #3 ), but kept stuck there, it looked something like this:
var shead = document.getElementById("sub-head"); if ($('#1').is(':visible') && $('#2').is(':hidden') && $('#3').is(':hidden')) { shead.style.color = "blue"; }
I repeated this for each of the slides, using :visible and :hidden for each of the divs, respectively, although I only ever went in cycles in the last presentation of the style color change.
I did a few searches about this and I saw people using .carousel(1) , but I just seem to continue the dead end, can someone give me a hand with this, not sure why it is not catching, there are no indications to be appreciated.
HTML
<header id="Carousel" class="carousel slide carousel-fade"> <ol class="carousel-indicators"> <li data-target="Carousel" data-slide-to="0" class="active"></li> <li data-target="Carousel" data-slide-to="1"></li> <li data-target="Carousel" data-slide-to="2"></li> </ol> <div class="carousel-inner"> <div class="item active" id="1"></div> <div class="item" id="2"></div> <div class="item" id="3"></div> </div> </header>
JAVASCRIPT
if ($('#Carousel').carousel(1).hasClass('active')) { alert("this is an alert"); }
javascript html twitter-bootstrap
Meeps
source share