ССылка
кусок html для первого
a id="myBtn"><img src="img/low1.png"></a>
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close>×</span>
</div>
</div>
<script src="js/script.js"></script>
Js для первого
var modal = document.getElementById('myModal');
var btn = document.getElementById("myBtn");
var spa = document.getElementsByClassName("close")[0];
btn.onclick = function() {
modal.style.display = "block";
}
spa.onclick = function() {
modal.style.display = "none";
}
window.addEventListener ('click', function (event) {
if (event.target == modalz) {
modalz.style.display = "none";
}
})
html для второго
<button id="raz">Open modal</button>
<div id="two" class="modal">
<div class="contmod">
<span class="close">×</span>
<p> modal</p>
</div>
</div>
<script src="js/script1.js"></script>
var two = document.getElementById('two');
var raz = document.getElementById("raz");
var spaned = document.getElementsByClassName("close")[0];
raz.onclick = function() {
two.style.display = "block";
}
spaned.onclick = function() {
two.style.display = "none";
}
window.onclick = function (event) {
if (event.target == two) {
two.style.display = "none";
}
}