I am new to Javascript / jQuery and I am trying to create a play button to play HTML5 video. My code is:
var video = $('#myVideoTag');
$('.btnPlay').on('click', function() {
if(video[0].paused) {
video[0].play();
}
else {
video[0].pause();
}
return false;
});
I keep getting this error:
$(".btnPlay").on is not a function
[Break On This Error]
$('.btnPlay').on('click', function() {
I can’t find out in my life what’s wrong. I have a .btnPlay class correctly defined on the page. I am following a tutorial that seems to use the same method without problems. Any ideas?
source
share