Basically, it’s what the question says. I need a div to fadeIn and another fadeOut (or show, I just used fadeIn) when a video ends, but only when it’s the last video in an array of 6. I have
$("#myVid").bind("ended", function() {
if(currentVideo == videos.length) {
$(".control").fadeOut();
$("#final").fadeIn();
}
and I’ve tried
$("#myVid").bind("ended", function() {
if(currentVideo == 6) {
$(".control").fadeOut();
$("#final").fadeIn();
}
so, I should be doing it’s job, but something isn’t doing it, but I can’t figure it out… Can I get some help here?
In an array of 6, the last item has the index 5 (index is zero-based). So if your
currentVideois an array index, you shouldcurrentVideo == videos.length-1. That’s the only obvious mistake I noticed in your script.