Please hover over the materials or tell me which functions to study. It is necessary after clicking on the button one pop-up window to close and open another using JS.

Closed due to the fact that the issue is too general for the participants Grundy , Kromster , Alexey Shimansky , aleksandr barakin , user207618 13 May '17 at 14:56 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    Attach your code (modal windows) to understand exactly how it is implemented - Denis Bubnov

2 answers 2

You probably should clarify the question.

alert('Нажмите ОК для открытия другого модального окна'); confirm('Ну как, открылось?') 

    Below is the most basic approach. But it can be developed depending on your needs.

     var button = document.getElementById('button'), first = document.getElementById('first'), second = document.getElementById('second'); // Отслеживаем клик button.addEventListener('click', function() { // Закрываем первый поапа first.classList.remove('opened'); // Открываем второй second.classList.add('opened'); }); 
     .popup { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #eee; display: none; } .popup.opened { display: block; } 
     <div class="popup opened" id="first"> first <button id="button">toggle</button> </div> <div class="popup" id="second">second</div> 

    • What is a modal window? The modal window should block the rest of the interface - Darth
    • The point is how to make one block visible and hide another. Make it so that the block overlaps everything using CSS. This is a manual dexterity, but the essence remains the same: codepen.io/shugich/pen/bWvoWE If you need system modal windows, then this is a completely different story. In your answer, you describe the essence. - dmitryshishkin
    • On the issue it is not completely clear what the author needs, I assumed that it was this. - dmitryshishkin
    • I did not think that so quickly begin to respond. I have several modal windows. Everyone has their own id. Suppose a person has opened a photo on the site (it is in the sodal window) - and there is a "buy" button. Someone asked for code modal windows, I use bootstrap - Vipz
    • one
      I corrected the answer, look this is what you need? - dmitryshishkin