After clicking a div, an image appears and the user can click the image to hide it. To prevent the user from accidentally closing the image while waiting for it to appear, I want to disable all clicks on the page for a few seconds after the div is clicked.
My approach involves using JavaScript to handle the show/hide functionality of the image.
function showCard(element) {
var id = element.id;
var image = document.getElementById(id);
var container = document.getElementById("cards");
if (image.style.display === "none") {
image.style.display = "block";
container.style.display = "block";
} else {
image.style.display = "none";
container.style.display = "none";
}
}
I've successfully implemented a similar feature for a button in the past, but I'm unsure how to disable clicks when it's not a button.
Any advice on how to achieve this would be greatly appreciated. Thank you in advance!