I\'m trying to call up a click element to open up a modal box, and i\'m unsure what I\'m doing wrong.
I\'ve done basic debugging, but I\'m still relatively new to this,
That happens because click onto tag forces browser to follow provided link. So page reloads.
var focus = document.getElementById("teal");
var modal = document.getElementById("bg-modal");
if (focus) {
focus.addEventListener("click", function(event) {
event.preventDefault();
modal.style.display = "flex";
});
}
I also saw your duplicate question, where you provided tag.
Move javascript file import from top of the
tag to bottom of the
tag