Good afternoon, I have a question - I made a pop-up window on js+html , it has functionality. But it turned out that there will be a lot of windows ... How better to be in such a situation: write a lot of windows and show them display:block; and hide them display:hide; or can it somehow be implemented in the 1st window, somehow magically replacing the content in it?

I will give an example:

 <div class="popup newaction"> <div> <div class="popup print"> <div> <div class="popup info"> <div> 
  • z-index can help control the visibility of blocks. - zloctb

3 answers 3

It depends on how the windows differ. If, for example, they differ only in content (for example, there is a title and text) and color, then it is logical to make one block and describe it.

Here is an example on jQuery . Accordingly, you can hide the popup using


    Everything has been written for a long time) Take advantage of Colorbox

    You can create a pop of any complexity with any content.

      If there can be only one open window, and the windows are the same, then of course it is better to replace only the content. For example, store content in hidden blocks and paste into popup.


      If there is a lot of content, it can be stored in separate pages and uploaded with ajax

       $("#popup").load("page1.html", function() { openPopup() }) 

      One window saves page size and it will be convenient to correct styles.

      But if, of course, all the windows are different, or can be open at one time, then you need to make separate popups.