0

I'm trying to make a container show up and disappear clicking the same button.

 <li><a href = "#" onclick = "contactVisibility();" >Contact</a></li>
<div id = "contact">
    <p>test@outlook.com</p>
    <a href="https://twitter.com/">Twitter</a> <br>
    <a href="https://www.instagram.com/">Instagram</a>
</div>
let contactState = 1
document.getElementById('contact').style.visibility = 'hidden';
function contactVisibility() {
    if (contactState = 1){
        document.getElementById('contact').style.visibility = 'visible';
    } else {
        document.getElementById('contact').style.visibility = 'hidden';
    }
    contactState *= -1
    console.log(contactState)
}

I tought that I could keep multiplying a number to -1 and than check its sign to know if the container is showing or not and run the right function but it doesn't seem to work and I really don't understand what's wrong.

0 Answers0