mardi 28 juin 2016

jQuery fadeIn() between if and else

I want to fade between different images which are loaded when different things happen. I created some if, else rules and thought I can tell jQuery with the fadeIn() to fade in every new image. But it's not working and I don't know why. I think it's a super little code thing I can't figure out. Hope you guys can help me!

Here is my code so far:

if(count == 1){
    $('.star').html('<img src="' + stern1 + '">').delay(1000).fadeIn('slow');
} else if (count == 2){
    $('.star').html('<img src="' + stern2 + '">').delay(1000).fadeIn('slow');
} else if(count == 3){
    $('.star').html('<img src="' + stern3 + '">').delay(1000).fadeIn('slow');
} else if(count == 4){
    $('.star').html('<img src="' + stern4 + '">').delay(1000).fadeIn('slow');
} else if(count == 5) {
    $('.star').html('<img src="' + stern5 + '">').delay(1000).fadeIn('slow');
} else {
    $('.star').html('<img src="' + stern1 + '">').delay(1000).fadeIn('slow');
}

Aucun commentaire:

Enregistrer un commentaire