Light
Light

Reputation: 1677

Create new HTML5 video element throught JavaScript

I am trying to create a new HTML5 video elemnt entirely throught JS. So I try to do it the same way I create a new image, like: obj = new Image() I write obj = new HTMLVideoElement(). However this doesn't work. I get the runtime error: Object doesn't support this action. What is wrong? Thanks.

Upvotes: 8

Views: 9045

Answers (1)

Alnitak
Alnitak

Reputation: 339917

The Image class is a special case.

The standard way to create any arbitrary HTML element is this:

var obj = document.createElement('video');

Upvotes: 18

Related Questions