P
P
pizza69142020-04-18 20:36:28
JavaScript
pizza6914, 2020-04-18 20:36:28

Why doesn't the modal exit work?

let 
                 tdone = document.getElementById('tdone'),
                  modalone = document.getElementById('modalone'),
                  tdtwo = document.getElementById('tdtwo'),
                  modaltwo = document.getElementById('modaltwo');
              
                 tdone.onclick = function(){
                     modalone.style.display= "block";
                 };
               window.onclick = function (e){
                    if(e.target == modalone) {
                     modalone.style.display="none";
                       } 
                    };
              tdtwo.onclick = function(){
                     modaltwo.style.display= "block";
                 };
               window.onclick = function (e){
                    if(e.target == modaltwo) {
                     modaltwo.style.display="none";
                       } 
                    };


The second modal closes, but the first does not. But if you delete the second window then the first one will close. How to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tigran Abrahamyan, 2020-04-18
@pizza6914

window.onclickwrite once.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question