hello guys, im needing some help here. i started to learn java this week, and i havi this function to change the image source, but, it just changes once, and i want it to change everytime i click on the button.
some ideias of what can i do?
this is the code:
<html>
<body>
<div onclick= "changeIcon()">
<img id="icon" src=play.svg height="250px"></img>
</div>
<script>
var icon = document.getElementById("icon");
function changeIcon() {
if (icon.src="play.svg")
icon.src="pause.svg";
else
icon.src="play.svg";
}
</script>
</body>
</html>
[off-topic]
When you post code in the forum, you need to format it. To do so you can either select all the code and click the </> button, or type 3 backticks ``` on a separate line both before and after the block of code.