Created
April 22, 2020 18:52
-
-
Save rvizena/83e17144ddddde3a99c6c1b8f82da0a9 to your computer and use it in GitHub Desktop.
HTML5 Video Toggle Play/Pause
This file contains 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
// HTML5 video element with button toggle | |
$('button').click(function () { | |
var mediaVideo = $("#myVideo").get(0); | |
if (mediaVideo.paused) { | |
mediaVideo.play(); | |
$('.pause').show(); | |
$('.play').hide(); | |
} else { | |
$('.play').show(); | |
$('.pause').hide(); | |
mediaVideo.pause(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment