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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -