get Canvas object with jQuery - why do I get an array?
Hi there
I'm playing around with the new HTML5 canvas element.
-
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "rgb(200,0,0)";
ctx.fillRect (10, 10, 55, 50);
Translating that to jQuery:
-
var canvas = $('#canvas');
var ctx = canvas[0].getContext("2d");
ctx.fillStyle = "rgb(200,0,0)";
ctx.fillRect (10, 10, 55, 50);
What I dont get is, why does $('#canvas') return an array object? Why can't I just simply use canvas.getContext("2d"); ?
Please enlighten me
Thanks a lot