Play/pause HTML 5 video using JQuery Play/pause HTML 5 video using JQuery jquery jquery

Play/pause HTML 5 video using JQuery


Your solution shows the issue here -- play is not a jQuery function but a function of the DOM element. You therefore need to call it upon the DOM element. You give an example of how to do this with the native DOM functions. The jQuery equivalent -- if you wanted to do this to fit in with an existing jQuery selection -- would be $('#videoId').get(0).play(). (get gets the native DOM element from the jQuery selection.)


You can do

$('video').trigger('play');$('video').trigger('pause');


This is how I managed to make it work:

jQuery( document ).ready(function($) {    $('.myHTMLvideo').click(function() {        this.paused ? this.play() : this.pause();    });});

All my HTML5 tags have the class 'myHTMLvideo'