Reputation: 46479
<a href="#page" class="lil-close">Close</a>
I have this button to close a lightbox. The lightbox contains a YouTube video and when I close the lightbox YouTube video keeps playing, I assume this will happen with all videos (not only YouTube). Is there a way (jQuery/JavaScript) to pause video once a user clicks a button?
Upvotes: 0
Views: 3996
Reputation: 14219
Try this function which uses YouTube's API and YouTube's Chromeless Player:
function pauseVideo() {
if (ytplayer) {
ytplayer.pauseVideo();
}
}
See an example here
Upvotes: 3