0
Uncaught type error; cannot read properties of getContext JAVASCRIPT
I wrote Var canvas = document.getElementById('canvas') Var context = canvas.getContext("2d") But it gets an error help pls I made a canvas in html with a black border and I wanna fill it ;-; thanks in advance
3 Answers
+ 3
Try to put canvas before style, but it's best to write styles in CSS
+ 4
Show your code.
Have you given your canvas an id with the same name?
+ 1
Solo html code
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<style>
#canvas {
width:150px; height:150px;
border:2px solid black;
}
</style>
<canvas id="canvas"></canvas>
</body>
</html>