Skip to content

Instantly share code, notes, and snippets.

View anam-hossain's full-sized avatar

Anam Hossain anam-hossain

View GitHub Profile
@anam-hossain
anam-hossain / modal-video-full.html
Created May 8, 2015 01:49
Full example - autoplay youtube video in a Modal (Bootstrap + Jquery)
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script>
$(function() {
$(".video").click(function () {
var theModal = $(this).data("target"),
videoSRC = $(this).attr("data-video"),
@anam-hossain
anam-hossain / modal-video.js
Last active August 29, 2015 14:20
Autoplay youtube video in a Modal (Bootstrap + Jquery)
$(".video").click(function () {
var theModal = $(this).data("target"),
videoSRC = $(this).attr("data-video"),
videoSRCauto = videoSRC + "?modestbranding=1&rel=0&controls=0&showinfo=0&html5=1&autoplay=1";
$(theModal + ' iframe').attr('src', videoSRCauto);
$(theModal + ' button.close').click(function () {
$(theModal + ' iframe').attr('src', videoSRC);
});
$(theModal).on('hidden.bs.modal', function (e) {
$(theModal + ' iframe').attr('src', videoSRC);