JSFiddle - React, Tailwind, and code Playground
HTML
<div class="change">
<img id=bg src="items/01.jpg" alt="" />
</div>
JavaScript
var images = ["02.jpg","03.jpg","01.jpg"];
$(function() {
$('.change').click(function(e) {
var image = images[Math.floor(Math.random()*images.length)];
$('#bg').parent().fadeOut(200, function() {
$('#bg').attr('src', 'items/'+image);
$(this).fadeIn(200);
});
});
});