1

это 2 разных js файла для каждого окна

var modal = document.getElementById('myModal');
var btn = document.getElementById("myBtn");
var span = document.getElementsByClassName("close")[0];

btn.onclick = function() {
  modal.style.display = "block";
}
span.onclick = function() {
  modal.style.display = "none";
}
window.onclick = function(event) {
  if (event.target == modal) {
    modal.style.display = "none";
  }
}





var modez = document.getElementById('modezl');
var YouBtn = document.getElementById("YouBtn");
var span = document.getElementsByClassName("close")[0];

btn.onclick = function() {
  modal.style.display = "block";
}
span.onclick = function() {
  modal.style.display = "none";
}
window.onclick = function(event) {
  if (event.target == modal) {
    modal.style.display = "none";
  }
}
!
<!DOCTYPE html>

<head>
  <meta charset="utf-8" />
  <title>Reveal Demo</title>


</head>

<body>
  <a id="myBtn"><img src="img/low1.png"></a>
  <div id="myModal" class="modal">
    <div class="modal-content">
      <span class="close"></span>
      <p>text</p>
    </div>
  </div>

  <a id="myBtn"><img src="img/low1.png"></a>
  <div id="YouBtnl" class="modal">
    <div id="modez" class="mod" <div class="contmod">
      <span class="close"></span>
      <p>text</p>
    </div>
  </div>
</body>

</html>

1 ответ 1

2

"два разных js файла" с одинаковыми названиями глобальных переменных? Второй файл перекрывает переменные и window.onclick из первого.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.