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 - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -