JSFiddle - React, Tailwind, and code Playground
HTML
<img src="http://placehold.it/94x95&text=img1" />
<img id="img2" src="http://placehold.it/94x95&text=img2" />
<script type="text/javascript">
//透過 document 物件與 id 取得網頁元素
var img = document.getElementById("img2");
img.onclick = function(){
var theimg = document.getElementById("img2");
theimg.src="http://placehold.it/94x95&text=Clicked";
}
</script>