JavaScript isn't my strong suit, so I'm struggling to solve this issue. The console is showing me the following error message:
Uncaught TypeError: Cannot set property 'onclick' of null
<script>
var modal = document.getElementById('modal');
var btn = document.getElementById("modalbtn");
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";}
}
</script>