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 jQuery Basics (2014) Creating a Simple Lightbox Perform: Part 2

Kerstyn Comley
Kerstyn Comley
2,996 Points

Why is is good practice not to edit the HTML text but instead use .append()

In the video Andrew says that the overlay should be appended by the JS file rather than adding it to the HTML file but why? He then goes on to add the overlay style to the CSS file which seems to contradict not adding it to the HTML file.

1 Answer

There is a lot of reasons why, but this article will spell it out better than I can explain it.

http://www.smashingmagazine.com/2008/09/jquery-examples-and-best-practices/#unobtrusive-dom-scripting

I hope this helps.

Kerstyn Comley
Kerstyn Comley
2,996 Points

thanks that's really helpful

Not a problem!