I don't understand what is wrong with my code. The if doesn't seem to be working in this case. I'd like the image to change when people click on the button. Can somebody help me please?
<div>
<img id="en_garde" src="gifattaque/gif1.png">
</div>
<br>
<button onclick=attaque_animation() type="button">Attaque</button>
<script>
function attaque_animation() {
if (document.getElementById("en_garde").src=="gifattaque/gif1.png") {
document.getElementById("en_garde").src="gifattaque/gif2.png";
}
};
</script>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire