Hello everyone, I have a CMS of video testimonials, that when clicked would pop out a modal that has some text description + the video itself (YouTube video).
The problem is, when the video continues to play even after I close the modal. I understand this requires a bit of Javascript which is well beyond my code knowledge.
var autoStopperBtn = document.querySelectorAll('.auto-stop');
for (var i = 0; i < autoStopperBtn.length; i++) {
(function(i) {
autoStopperBtn[i].onclick = function () {
var autoStopperModule = autoStopperBtn[i].closest('.auto-stopper');
var autoStopperFrame = autoStopperModule.querySelector('iframe');
var autoStopperSrc = autoStopperFrame.src;
autoStopperFrame.src = ''; // clears url, some browsers wont update the url if it matches existing value.
autoStopperFrame.src = autoStopperSrc;
}
}(i));
}
</script>