I've created a simple modal code with minimal JS involved. When the button is clicked, the modal appears briefly, then the page refreshes and the modal disappears. I'm not sure what could be causing this issue. Any help would be appreciated!
https://jsfiddle.net/wj3r2qzu/
var openModalBtn = document.querySelector("#open-modal-btn");
var backgroundModal = document.querySelector(".background-modal");
var closeModal = document.querySelector(".close-modal");
openModalBtn.addEventListener("click", function() {
backgroundModal.classList.add("active-bg");
});
closeModal.addEventListener("click", function() {
backgroundModal.classList.remove("active-bg");
});