Stop video in modal when modal is closed

PHOTO EMBED

Sun Mar 20 2022 18:00:19 GMT+0000 (Coordinated Universal Time)

Saved by @max_demydenko #js #youtube-embed #video #stop-video

/*JS*/
$("#{ID_OF_CLOSE_MODAL_BUTTON}").click(function(e) {
	const t = document.getElementsByClassName("{YOUR_MODAL_CLASSNAME}")[0].children[0].src;
	document.getElementsByClassName("{YOUR_MODAL_CLASSNAME}")[0].children[0].setAttribute("src", ""),
		document.getElementsByClassName("{YOUR_MODAL_CLASSNAME}")[0].children[0].setAttribute("src", t);
});
/*JS*/
content_copyCOPY

If you have a modal with video inside it you can see that when you play the video and then close the modal video is still playing. This code solves this bug.