There is a form which opens and closes and uses style="display: block"
when clicked to open and style="display: none"
when closed. I have used javascript to print to the console when each condition is met, however no matter what I try the if statement always remains visible
.
When I try to console.log
it returns the correct value of the current display option. Here is the code:
console.log(document.querySelector('.request-quote-form').style.display)
When I run the function it always prints out visible
. Any ideas? I have also tried this in jQuery and I'm receiving the same results.
document.querySelector('.js-request-quote-btn').addEventListener('click', function() {
console.log(document.querySelector('.request-quote-form').style.display);
if (document.querySelector('.request-quote-form').style.display === "block") {
console.log("visble");
} else {
console.log("nope");
}
});