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

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/