When I click on the overlay I want to stop the embed YouTube video and restart is so far I have this code but it when it closes its still going and not bother to stop and not giving any error.
function closeToogle(){ console.log(iframes); for (let portfolioItem of portfolioItems){ for(let iframe of iframes){ setTimeout(function(){ iframes[0].contentWindow.postMessage('{"event":"command", "func":"stopVideo","args":""}', '*'); }, 500); // add a 500ms delay iframe.style.pointerEvents = "none"; } portfolioItem.classList.add("hover-effect") portfolioItem.removeAttribute("id", "toogle") portfolioItem.removeAttribute("controls", "visable") overlayDiv.removeAttribute("id") }}I thought that it needs time to realize I want to close that's the only reason there is a delay on it, it might not even needed