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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -