Stop a youtube pop up modal as pressing X

Hi, I’ve read several posts about how to close and stop the video of a modal Youtube popup so it won’t play in the background. But I have a really hard time understanding what goes where.
I have successfully add the modal popup and the video plays I am not able, no matter what I’ve tried to get it to close after I hit the X.

I have used this -

$(document).ready(function() {
$(‘.modal-link’).click(function() {
$(‘.modal-background’).fadeIn();
});
$(‘.close-modal’).click(function() {
$(‘.modal-background’).fadeOut();
});
});

And I have tried to add - stopthevideo(); in the end but it doesn’t work (probably misunderstood how to use it).

I am new to webflow and have previous knowledge in code so it’s really confusing for me.
Hope you can help.

Thanks.

1 Like