I am trying to exit the popup card by clicking anywhere other than the card i.e. on the blurred background, but I am not able to add the EventListener to the div, because the class is toggled off and the error is Cannot read property 'addEventListener' of null at... This code doesn't work.
const blurMe = document.querySelector(".blur");
blurMe.addEventListener("click", function () {
for (let index = 0; index < 3; index++) {
card[index].classList.add("hidden");
}
blurMe.classList.remove("blur");
});
My cross button is working fine but I don't know how to add the feature to exit the popup just by clicking anywhere else on the screen. https://codepen.io/rhythmshandlya/pen/wvgMwyz please add the code to