$(".video-img").click(function () { var videosrc = $(this).data("info"); console.log(videosrc); let VideoContent = `
`; $('#video-modal').html(VideoContent); }); $('.play-video').click(function(){ $('.youtube-video')[0].contentWindow.postMessage('{"event":"command","func":"' + 'playVideo' + '","args":""}', '*'); }); // function autoPlayYouTubeModal() { // var trigger = $("body").find('[data-toggle="modal"]'); // trigger.click(function () { // var theModal = $(this).data("target"), // videoSRC = $(this).attr("data-theVideo"), // videoSRCauto = videoSRC + "?autoplay=1"; // $(theModal + ' iframe').attr('src', videoSRCauto); // $(theModal + ' button.close').click(function () { // $(theModal + ' iframe').attr('src', videoSRC); // }); // }); // } $(document).on("click", ".btn-close", function (event) { $('.youtube-video').each(function () { this.contentWindow.postMessage('{"event": "command", "func": "stopVideo", "args": ""}', '*'); }); console.log('stop'); }); $(document).on("click", "#exampleModal", function (event) { $('.youtube-video').each(function () { this.contentWindow.postMessage('{"event": "command", "func": "stopVideo", "args": ""}', '*'); }); // alert('111111') // window.location.reload(); });