JSFiddle - React, Tailwind, and code Playground
HTML
<script src='http://code.jquery.com/jquery-1.11.3.min.js'></script>
<div id="body" class="backgroundImage" style='background-image: url("http://lorempixel.com/300/200/sports/1"); max-width:200px; max-height:200px;'></div>
JavaScript
images = [
'http://lorempixel.com/300/200/sports/1',
'http://lorempixel.com/300/200/sports/2',
'http://lorempixel.com/300/200/sports/3',
'http://lorempixel.com/300/200/sports/4', // This seems to not be a valid image, but meh
];
index = 0;
$('.backgroundImage').click(function(){
if (index < (images.length-1)) { // This uses length-1 because the array is 0-indexed.
index++;
} else {
index = 0;
}
$(this).css({
'background-image' : "url(" + images[index] + ")",
});
});