How to create canvas in javascript

Any one help me to create canvas object in html using javascript.
Deepak Sharma
Asked 12-11-2024
182

Answer (1)
use the following code to create canvas object in html using javascript <canvas id="myCanvas" width="200" height="100" style="border:1px solid #c3c3c3;"></canvas> javascript is here:- var canvas = document.getElementById("myCanvas"); var ctx = canvas.getContext("2d"); ctx.fillStyle = "#FF0000"; ctx.fillRect(0,0,150,75);  
Harsh Aggrawal
Asked 04-01-2019
45 Likes
Comments
Write comment

Submit your answer