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
brandonlind2
7,823 PointsHow does .append() add things?
For example if I were to use .append('<div></div>') to add a div to the html body how would this be added, would it be added inside the body immediately after the body opening tag of after the body closing tag?
so like <body> <div></.div> </body>
or
<body> </body> <div></div>
2 Answers
Kelly von Borstel
28,880 PointsHi, Brandon. The .append() method will add the div to the end of body as the last child. (The .prepend() method adds it as the first child.) Here's a link to jQuery documentation explaining how .append() works. http://api.jquery.com/append/
sizwengubane
15,244 PointsHello Brandon the .append method in javascript is used to add content to the end of a certain element so if u want to add a div to the html body....the code is as follows:
$("body").append("<div></div>");
this will append the div element right before the closing body tag please rate my answer if i provided u the right solution
Kelly von Borstel
28,880 PointsKelly von Borstel
28,880 PointsSo it is inside the body, before the closing tag.