I'd appreciate a lot if someone could help me to solve a simple problem of code on codepen.io
(Surprisingly it works here too) but not on my pc. I've tried to add jQuery <script src="jquery-3.4.1.min.js"></script>
in a file which contains the code itself. But pop up window doesn't appear when clicked on button. What did I miss or do wrong? Thanks in advance
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";
}
};
.modal {
display: none;
position: fixed;
z-index: 9;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.4);
}
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
<!DOCTYPE html>
<html>
<head>
<script src="animate.js"></script>
<link rel="stylesheet" href="animate.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial, Helvetica, sans-serif;
}
</style>
</head>
<body>
<h2>hello</h2>
<button id="myBtn">Open</button>
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<p>Close</p>
</div>
</div>
</body>
</html>