How to on click yotube video play in popup

<a href="JavaScript:Void(0);" data-toggle="modal" data-src="” data-target=”#testimonial” class=”d-block video-link video_btn”><img class="d-block w-100" src="” alt=”” width=”100%” height=”100%” />

/********************************/

/********************************/
var $videoSrc;
$(‘.video-link’).click(function() {
$videoSrc = $(this).data( “src” );
});
//console.log($videoSrc);
// when the modal is opened autoplay it
$(‘#testimonial’).on(‘shown.bs.modal’, function (e) {

$(“#testimonial_video”).attr(“src”, $videoSrc + “?enablejsapi=1&rel=0&autoplay=1&amp;showinfo=0”);

})

// stop playing the youtube video when I close the modal
$(‘#testimonial’).on(‘hide.bs.modal’, function (e) {
// a poor man’s stop video
$(“#testimonial_video”).attr(‘src’,$videoSrc);

})

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.