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
Post a Comment