1
I’m trying to make the image change every time I click the button, so that when I click on image1 it becomes image2 and when I click not image2 it becomes image1
<script>
function changeImage(){
var image = document.getElementById("image");
if(image.src = "image1.png"){
image.src = "image2.png";
}
else if(image.src = "image2.png"){
image.src = "image1.png";
}
}
<img id="image" src="image1.png" width="490" height="364">
<button onclick="changeImage()">Mudar image</button>
only that it can only become image2, after that it is not back to image1