mardi 21 septembre 2021

Else Statement is not being executed [closed]

Hi guys I was in the middle of creating a simple dropdown menu for a project I'm working on but while I was implementing the JavaScript the else statement will not be executed.

Here is the to Codepen:

Dropdown menu in progress

And some js code:

//Product dropdown

var productDropdown = document.getElementById("productDropdown");
var productArrow = document.getElementById("productArrow");
var productToggle = document.getElementById("productToggle");

function product() {
  if ((productDropdown.style.display = "none")) {
    productDropdown.style.display = "block";
    productArrow.style.transform = "rotate(180deg)";
  } else {
    productDropdown.style.display = "none";
    productArrow.style.transform = "rotate(0deg)";
  }

  if ((productDropdown.style.display = "block")) {
    companyDropdown.style.display = "none";
    companyArrow.style.transform = "rotate(0deg)";

    connectDropdown.style.display = "none";
    connectArrow.style.transform = "rotate(0deg)";
  }
}

productToggle.addEventListener("click", product);

As you can see the code is there to make the dropdown disappear but it won't.

Aucun commentaire:

Enregistrer un commentaire