html5 - How to get a canvas element with JQuery? -


i've read: canvas - use []

var canvas = $("#canvas1")[0]; var x = canvas.getcontext("2d"); x.fillrect(50, 40, 55, 55);  /*var d = $("#div1"); d.css("background-color", "blue");*/ 

why can element, e. g. <div> id, if want canvas, must use [0]? not work without.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -