Skip to content

Instantly share code, notes, and snippets.

@Security2431
Last active July 5, 2017 08:25
Show Gist options
  • Save Security2431/34c5849b4f2ddc0c30796ab3992ef5ac to your computer and use it in GitHub Desktop.
Save Security2431/34c5849b4f2ddc0c30796ab3992ef5ac to your computer and use it in GitHub Desktop.
Video preview
$(function() {
$('#video__play').on('click', function(e) {
let dataYoutube = $(this).closest('.video').data('youtube');
$(this).replaceWith('<div class="embed-responsive embed-responsive-16by9"><iframe class="embed-responsive-item" src="https://www.youtube.com/embed/' + dataYoutube + '?autoplay=1" frameborder="0" allowfullscreen></iframe></div>');
e.preventDefault();
});
});
.video(data-youtube='8z9kooDFTSE')
a#video__play.video__play(href='#')
img.img-responsive.video__img(src='img/video.jpg', alt='Трейлер')/
<div class="video" data-youtube="8z9kooDFTSE">
<a class="video__play" id="video__play" href="#">
<img class="img-responsive video__img" src="img/video.jpg" alt="Трейлер">
</a>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment