var overlay = document.getElementById('overlay');
var vid = document.getElementById('video');
if(overlay.addEventListener){
overlay.addEventListener("click", play, false)
}else if(overlay.attachEvent){
overlay.attachEvent("onclick", play)
}
function play() {
if (vid.paused){
vid.play();
overlay.className = "o";
}else {
vid.pause();
overlay.className = "";
}
}
$(".video-player").each(function (videoIndex) {
var videoId = $(this).attr("id");
video(videoId).ready(function() {
this.on("play", function(e) {
$(".video-player").each(function (index) {
if (videoIndex !== index) {
this.player.pause();
}
});
});
});
});
Find more questions by tags JavaScript