I\'m trying to play a video as soon as the dom has loaded using jQuery. This is my code:
HTML
The jQuery selector $("#video")
returns a jQuery object. Since play()
is a function of the DOM element, you must get the DOM element with:
$("#video").get(0);
before using .play() method:
$("#video").get(0).play();
Edit: You can also use HTML5 selected tags in case jQuery fall back. Note the autoplay
tag.