Question
This code is not working. it works if i change the id of hidden to the class of hidden. im confused why this is happening.
This code is not working. it works if i change the id of hidden to the class of hidden. im confused why this is happening. why does it only work if the id is changed from id to class?
can you please let me know. thank you
#hidden {
display: none;
}
#modal {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: white;
padding: 20px;
}
This is a pop-up!
function setupModal() {
document.getElementById("button").addEventListener("click",()=>{
document.getElementById("modal").classList.remove("hidden");
});
document.getElementById("close-modal").addEventListener("click",()=>{
document.getElementById("modal").classList.add("hidden");
});
}
// call the setupModal function after the DOM has loaded
document.addEventListener("DOMContentLoaded", setupModal);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started