Reputation: 57
I am trying to learn how to use a canvas and i cannot for the life of me figure out why this basic code wont work does anyone know what I am doing incorrect?
<canvas id="ctx" width="500" height="500" style="border:1px solid #000000"></canvas>
<script >
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.fillText = ("hey", 50, 50);
</script>
Upvotes: 0
Views: 49
Reputation: 1841
You are passing the wrong ID to getElementById
. Your canvas id is ctx
not canvas
. Use document.getElementById('ctx').
Upvotes: 1