mercredi 29 avril 2015

Query if else if else check true?

Hello i want to check if a div has the class active. the first item works, after that it stops. Can someone tell me how to fix this? (Its a slider, so it has to work not on click.) It slides automatic.

    <script>
$(document).ready(function () {
  if ($('#211').hasClass('item active')){
            $('.vandaag').css("background-color", "blue");
            console.log("werkt1!");}
   else if ($('#218').hasClass('item active')){
            $('.vandaag').css("background-color", "#005993");
            console.log("werkt2!");}

    else if ($('#219').hasClass('active')){
            $('.vandaag').css("background-color", "#005993");
            console.log("werkt3!");}
});

</script>

the number is the id of the image slider. and the .item .active is when the slide is active. Greetz

Aucun commentaire:

Enregistrer un commentaire