0
Why can't I change the color of my canvas?
I've tried everything and can't seem to get my canvas to change color https://code.sololearn.com/WEP8gu3YmRYh/?ref=app
3 Respuestas
+ 2
You got a typo at line 6, in JS section
c.fillStyle = "red"; // c.fillStlye = "red"
P.S. Can you please delete the duplicate of this one you posted earlier?
0
Still can't get it to work
0
Don't use 'onload' attribute in <body> (line 6 HTML section)
Instead, use window.onload event handler function directly in JS section
window.onload = function()
{
const canvas = document.querySelector("canvas");
const c = canvas.getContext("2d");
canvas.width = 200;
canvas.height = 200;
c.fillStyle = "red";
c.fillRect(0,0,canvas.width,canvas.height);
c.clearRect(100,100,50,50);
}