I am trying to loop list of iframe videos. If one video is playing others are hidden. When I switch to another video and come back to the previous video, it does not show and play.
This is my code, what am I doing wrong?
for (var i = 0; i < youtube.length; i++) {
$(youtube[i]).on('hidden.bs.collapse', function () {
$('iframe').attr('src', '');
});
$(youtube[i]).on('show.bs.collapse', function () {
$('iframe').attr('src', "https://www.youtube.com/embed/" + this.dataset.embed + "?rel=0&showinfo=0&autoplay=1");
});
}