Last active
August 29, 2015 14:20
-
-
Save anam-hossain/a0527be17a59b18fc2c4 to your computer and use it in GitHub Desktop.
Autoplay youtube video in a Modal (Bootstrap + Jquery)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".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); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment