Stop youtube video when popup is closed

I am now a programmer and getting to know css.
I am student in Graphic Design building a website with WordPress and the Divi theme for my grand project.
There is a plugin “Bloom” that will popup an embedded html youtube iframe, but when it is closed the video keeps playing. i have searched for a couple of days on the forums and could not quite understand how to make it stop.

Here is my html for the popup.

 <iframe id="ytvideo2" width="640" height="360" src="" frameborder="0" allowfullscreen></iframe>

And the script that i found on the forums.

//First get theiframe URL
var url = $('#ytvideo').attr('src');

//Then assign the src to null, this then stops the video been playing
$('#ytvideo').attr('src', '');

// Finally you reasign the URL back to your iframe, so when you hide and load it again you still have the link
$('#ytvideo').attr('src', url);

I don’t even know if this is the right script for me and where it supposed to go. 🙁
Hope anyone could help me.
Thanks in advance.

Read more here: Stop youtube video when popup is closed

Leave a Reply

Your email address will not be published. Required fields are marked *