0

I am trying to make a switch button in html and javascript but is not working, the button change one time and then it stay pressed.

The html code:

<div class="button-div" unselectable="on">
        <img id="button" src="images/button/button.png" onclick="btnClick()">
</div>

The javascript code:

if (document.getElementById('button').src = "images/button/button.png"){
        document.getElementById('button').src = "images/button/buttonPressed.png";
    }else{
        document.getElementById('button').src = "images/button/button.png";
}

0 Answers0