I have a basic overlay where when a specific link is clicked content is displayed over the top of the page. This works fine but I've just added a YouTube video embed and realised when the overlay is closed the sound plays in the background. So I need to find a way to stop or pause the video. I'm inherited the code, here it is:
$('#size-guide a').click(function(e){
e.stopPropagation(); e.preventDefault();
$('.sizeguide-popup-container').addClass('reveal');
$('html,body').addClass('noscroll');
$("header.mainHeader").css("position", "absolute").css("z-index", "100");
});
$(document).on("click", ".sizeguide-popup-close", function() {
$(".sizeguide-popup-container").removeClass('reveal');
$('html,body').removeClass('noscroll');
$("header.mainHeader").css("position", "fixed").css("z-index", "9999999");
});
$('.sizeguide-popup-container').on('click', function(e) {
if (e.target !== this)
return;
$('.sizeguide-popup-container').removeClass('reveal');
$('html,body').removeClass('noscroll');
$("header.mainHeader").css("position", "fixed").css("z-index", "9999999");
});
I guess it's just the 2nd block I need to amend but what I've tried so far hasn't done the trick. The video is automatically wrapped in a rte__video-wrapper
div to make it responsive. So I thought I could amend it to something like the following (after reading another thread):
$(document).on("click", ".sizeguide-popup-close", function() {
$(".sizeguide-popup-container").removeClass('reveal');
$('html,body').removeClass('noscroll');
$("header.mainHeader").css("position", "fixed").css("z-index", "9999999");
$(".rte__video-wrapper iframe").attr('src','');
});
As that essentially just removes the videos link so when the overlay is reopened there's a big blank space. Anyone point me in the right direction?