Ben
Ben

Reputation: 37

Disabling display on a div

So I'm trying to remove display until a var is met, but it isn't working properly, any help?

       function test() {
   var x = document.getElementById('trash_01');
   if (trashcan = 0) {
   x.style.display = "none";
  }
 }

Upvotes: 0

Views: 26

Answers (2)

LightNow
LightNow

Reputation: 11

you make the mistake the same as this guy: Input's placeholder won't change from <select> '=' means assignment,two or three '=' just means if equal,good luck

Upvotes: 0

vityavv
vityavv

Reputation: 1490

You put trashcan = 0 instead of trashcan === 0 in your if statement, so it assigns 0 to trashcan instead of checking if it is 0

Upvotes: 2

Related Questions