var modal = document.getElementById("myModal");
var myBtn = document.getElementsByClassName("btn__modal-cost");
var close = document.getElementsByClassName("modal-cost__close")[0];
for (var i = 0; i < myBtn.length; i++) {
myBtn[i].addEventListener("click", function() {
openModalWindow();
});
}
close.addEventListener("click", function() {
closeModalWindow();
});
function openModalWindow() {
modal.style.display = "block";
}
function closeModalWindow() {
modal.style.display = "none";
}
position: fixed;
top: 0; bottom: 0; left: 0; right: 0;
opacity: 0.5;
background-color: black;
// вот это
close.addEventListener("click", function() {
closeModalWindow();
});
// можно заменить на
close.addEventListener('click', closeModalWindow)