Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Rohit Patwari5,500 Points
$("canvas") and $("canvas")
Whats the conceptual difference . I thought the first one ie $("canvas") is actually represents the html element in the DOM
Joshua Ferdaszewski12,716 Points
The best way to think about a jQuery object is as a wrapper of zero or more DOM elements. It behaves somewhat like an array, but as this documentation says:
Many developers new to jQuery assume that this collection is an array. It has a zero-indexed sequence of DOM elements, some familiar array functions, and a .length property, after all. Actually, the jQuery object is more complicated than that.
As a wrapper, it smooths out some compatibility issues (i.e. IE) and adds convenience methods that help with some of the more cludgy parts of dealing with the DOM. Another important piece is that methods on jQuery objects return jQuery objects. So method calls can be strung together.
I would recommend checking out the above article as well as the jQuery Documentation itself. Good luck with your learning!
$("canvas") represents an array (jQuery Object) of all objects matched by the selector.
$("canvas") represents the first object in that array. Hope that''s understandable.