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
Get step-by-step solutions from verified subject matter experts
