Why doesn't the output from modal window?

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";
 } 
 };


Second modal window closes, but the first is not. But if you delete the second window then the first will close. How to fix it?
April 19th 20 at 12:44
1 answer
April 19th 20 at 12:46
Solution
window.onclick write once.
thank you - abigail.Harb commented on April 19th 20 at 12:49

Find more questions by tags JavaScript