Skip to content

Instantly share code, notes, and snippets.

@WebCulT
Created May 26, 2019 08:19
Show Gist options
  • Save WebCulT/b79a50e3ef21ccf160a01910365d51d6 to your computer and use it in GitHub Desktop.
Save WebCulT/b79a50e3ef21ccf160a01910365d51d6 to your computer and use it in GitHub Desktop.
Example of video tag
<button class="button video__play">Play</button>
<video width="305" height="170" poster="img/bg-video.jpg">
<source src="#" type='video/ogg; codecs="theora, vorbis"'>
<source src="#" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
<source src="img/9-7_RU-208934200_01.webm" type='video/webm; codecs="vp8, vorbis"'>
</video>
var startVideo = function() {
$('.video').on('click', function(e) {
var currentElem = e.target.closest('.video__play'),
currentVideo = null;
if(!currentElem) return;
currentElem.hidden = true;
currentVideo = currentElem.nextElementSibling;
currentVideo.setAttribute('controls', '');
currentVideo.play();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment