- 2
Weill some kind person tell me what is wrong with this code?
What is wrong with this code? </body> </html> var c=document.getElementById("canvas1"); var ctx=c.getContext("2d"); ctx.fillRect(20,20,100,100); <!DOCTYPE html> <html>
2 Respuestas
+ 1
For starters, that's not how html works. What you wrote is fully nonsensical. If you want javascript inside you html file, you should do it like this:
<html>
<head>
...
</head>
<body>
...
<script>
...
</script>
</body>
</html>
0
All wrong.
<!DOCTYPE html>
<body>
<canvas id="canvas1"></canvas>
<script>
var c=document.getElementById("canvas1");
var ctx=c.getContext("2d");
ctx.fillRect(20,20,100,100);
</script>
</body>
</html>
https://www.sololearn.com/learn/HTML/2201/