javascript - Trying to make a button switch between two different values -


i don't know if sort of loop protection, want button when clicked toggles image on or off , code not working:

<script>                             document.getelementbyid('standbybutton').onclick = function() {                          if (document.queryselector('#standby img').style.visibility = 'hidden'){                                 document.queryselector('#standby img').style.visibility = 'visible'                          } else {                                 document.queryselector('#standby img').style.visibility = 'hidden'                           } return false;  }                    </script> 

what missing? if image hidden, make visible. if else, make hidden. no?

you're using assignment operator (=) , not comparison operator (== or ===).

edit: fyi, jslint (or similar) have caught this.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -