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 trialKuzo Geko
Full Stack JavaScript Techdegree Student 3,271 PointsI really don't understand what jquery object is.
Hello, in the video andrew talk about jquery object. And that we can select an element not yet in the DOM by this particular code
$element = $("<element></element>");
Then we can manipulate this with jquery methods. But It's hard to me to apprehend this concept.
So can someone explain to me.
Thank you
1 Answer
Steven Parker
231,236 PointsI think of a jQuery object as an "element in a box".
Actually, it's a box containing one or more elements. Any jQuery method used on the "box" will affect all the elements in the box (unless the method is specifically designed to work on only the first one).
The element(s) in the box may or may not be currently part of the DOM. The element(s) in the box may be added to or removed from the DOM by some of the methods.
test = document.getElementById("test");
$test = $(test); // $test is a jQuery object containing the element with id="test"
// same concept, but done in one step:
$sample = $("#sample"); // $sample is a jQuery object containing the element with id="sample"
Does that help?
Kuzo Geko
Full Stack JavaScript Techdegree Student 3,271 PointsKuzo Geko
Full Stack JavaScript Techdegree Student 3,271 PointsYep, thank you. It's more comprehensible