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 trialEni Begotaraj
13,723 Points.append method vs .html
Hey guys,
On the first video Dave used .html(...... <strong>....</strong>...) method to add some text and now to add the e-mail he used .append method. Is there any difference between each other??
1 Answer
Leslie Heinzen
26,662 Points.append() will tack on the given HTML to the end of the already present HTML in the element that you're calling .append() on, whereas .html() will overwrite the inner HTML that is currently present in the element with the new HTML that you've passed in. If the element is empty, or if you want to replace the inner HTML of an element, then .html() is very handy. If you want to add a new string of html to an element (say, for example, you want to dynamically add a new list item), then .append() is great.
Eni Begotaraj
13,723 PointsEni Begotaraj
13,723 PointsThank you for your answer. It was very helpful.