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 trialWerner Chao
Courses Plus Student 1,951 PointsRegarding moving '2. Add overlay' to top
Hi, I didn't understand why the instructor decided to move the '2. Add overlay' to top, above the original step 1. This line here:
$("body").append('<div id = "overlay"></div>');
I understand that it is useful to use the overlay as a variable, but I don't understand why and how it affects the outcome by moving 'Step 2. Add overlay' to top.
Thanks!
1 Answer
Sergey Podgornyy
20,660 PointsBecause he want to create this element first and show it only after click on image.
Werner Chao
Courses Plus Student 1,951 PointsWerner Chao
Courses Plus Student 1,951 PointsAh I see! Thank you! What would happen if he creates the element only after click on image? Would that work?
Sergey Podgornyy
20,660 PointsSergey Podgornyy
20,660 PointsYou are welcome!
Yes, it will work, but then you need to create new element every time you press the button. And then remove this element from DOM tree.
If you once created this element, everything you need - just show and hide it.