Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Jasiu Hanc
Jasiu Hanc
8,341 Points

appending $image to $overlay

Hi,

I have a problem understanding this.

When we write:

var $overlay = $("<div id="overlay"></div>"); var $image = $("<img>"); $overlay.append($image); $("body").append($overlay);

Andrew says that it will append both of them to the body and I get that but then @1:22 he says: "So the structure's now like the body has the div of id overlay added. And within that div, we get the image added."

I thought append means we append at the end of the element so how can it append $image in the middle of the $overlay string?

1 Answer

If you check out the jQuery Docs you can find the .append() function under DOM Manipulation > Insertion, Inside It throws me off too http://api.jquery.com/category/manipulation/dom-insertion-inside/