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

In this case: prepend(); or append(); ?

I'm seeing the course, while doing a Modal Box in a project. Im passing dynamically with #overlay.css(); the top property with the value that Im catching from the $(window).scrollTop();

My Error:

  • When I click my button to execute #overlay.show() for the first time, works Great.
  • After I click my ''Close Button'' and execute #overlay.hide() it also works.
  • But, when I click again for second time my button to execute #overlay.show() its appending the DIV at the end of the body.

I did fix it using prepend(); instead append(); on the body.prepend(#overlay); ---only in that part off course...

my question::

It's not better prepend() building a modal box ? Or my error should be due to something else in my code, and append also toggle the thing good ...?

1 Answer

Hi there Rolandoo!

It's hard to say what you are doing wrong . Show your code, and after community members saw it, they will eventually give a proper answer.

Here is the good guide how to build a modal

Best regards.

Thanks for answer Serhii, I appreciated it. I fixed the mistake already. :)