I have a button that, when clicked, reveals hidden text by changing its CSS display property to "block". However, when I click the button, the text briefly shows up and then immediately disappear afterwards. How do I fix this?
const contactPopUp = document.getElementById("contactButton");
const exitButton = document.getElementById("exit");
function showPopUp() {
document.getElementById("contacts").style.cssText =
"display: block; position: absolute; top: 30%; right: 40%; background-color: rgb(0, 0, 119); font - family: verdana, sans - serif; color: white; padding: 30 px;";
}
function closePopUp() {
document.getElementById("contacts").style.display = "none";
}
contactPopUp.addEventListener("click", showPopUp);
exitButton.addEventListener("click", closePopUp);
#contacts {
display: none;
position: absolute;
top: 30%;
right: 40%;
background-color: rgb(0, 0, 119);
font-family: verdana, sans-serif;
color: white;
padding: 30px;
}
#contact_list {
display: block;
font-family: verdana, sans-serif;
color: white;
}
<div id="header_container">
<ul>
<li id="homepage_name">text</li>
<li><a href="">Home</a></li>
<li><a href="">About us</a></li>
<li><a id="contactButton" href="">Contacts</a></li>
</ul>
</div>
<div id="contacts">
You may contact us at: <button id="exit">X</button>
<ul>
<li id="contact_list">Insert Contacts Here.</li>
<li id="contact_list">Insert Contacts Here.</li>
<li id="contact_list">Insert Contacts Here.</li>
</ul>
</div>