im trying to toggle a variable with a button the code doesnt toggle it only outputs what the variable initially was
<button id="lock" onclick="togle()">
<img id="img1" src="images/lock.png" class="center" >
<script>
var mode = false;
function togle(){
if (mode == true) {
mode = false;
} else {
mode = true;
}
}
</script>
result is always the default variable
the variable should toggle between true and false but it just stays what it is
Aucun commentaire:
Enregistrer un commentaire