JSFiddle - React, Tailwind, and code Playground
HTML
<img name="myButton" id="myButton" data-img="1" src="https://www.dictionary.com/e/wp-content/uploads/2018/03/waifu.jpg" />
JavaScript
var imgList = ["https://www.dictionary.com/e/wp-content/uploads/2018/03/waifu.jpg","http://media.japanpowered.com/images/tsutsukakushi_tsukiko.jpg", "https://i.ebayimg.com/images/g/9-cAAOSwP6pZmoLs/s-l300.jpg" ];
var myButton = document.getElementById("myButton");
myButton.onclick = function( e ){
var elem = e.target,
imageIndex = parseInt(elem.dataset.img,10);
if( imageIndex <= (imgList.length -1) ) {
elem.src = imgList[imageIndex++];
elem.dataset.img = imageIndex;
} else {
elem.src = imgList[0];
elem.dataset.img = 1;
}
}