Computer >> Computer tutorials >  >> Programming >> Javascript

Can the HTML5 Canvas element be created from the Canvas constructor?


No, you cannot create the HTML5 Canvas from the canvas constructor. You need the following −

document.createElement('canvas');

Use the following −

var canvas1 = document.createElement("canvas");
canvas1.id = "canvas1";

document.body.appendChild(canvas1);