在我按下按钮一次后,如何使图像切换回原始图像 src

How to I make the image switch back to the original image src after Iv'e pressed the button once

<html>
<body>

<button onclick="document.getElementById('myImage').src='hagthrowingball.gif'">Throw Fire ball</button>

<img id="myImage" src="foresthag.gif" style="width:100px">


</body>
</html>

我需要图像 src onclick 来显示图像 hagthrowingball.gif,但无需再次按下按钮即可返回 foresthag.gif。

我认为这应该可以通过在一段时间后自动设置回旧 src 来解决您的问题;

<button onclick="replaceFunc();">Throw Fire ball</button>

<img id="myImage" src="foresthag.gif" style="width:100px">

<script>
  function replaceFunc (){
      const el = document.getElementById("myImage");
      const oldSrc = el.src;
      el.src = 'hagthrowingball.gif';
      setTimeout(()=>el.src=oldSrc, 1000);
  }
</script>
</body>
</html>