How do you check if a set of elements (7 total), that all have the same class name, all have the display
property set to none
, using Javascript? If all those display
properties are set to none
then set the button disable = false
. If any of those elements, even just one, have display
equal to block
, set the button disable = true
. Below is the failing attempt:
const errorMessages = document.querySelectorAll(".invalid-password")
const submitButton = document.querySelector("#account_submit")
submitButton.addEventListener("click", () => {
errorMessages.forEach(message => {
if (message.style.display !== "none") {
submitButton.disabled = true;
} else {
submitButton.disabled = false;
}
})
})