JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/ui-lightness/jquery-ui.css">
<center>
    <p>
        This Javascript Example will change the background image of<br />
        HTML Div Tag onclick event.
    </p>
    <div id="div1">
    </div>
    <br />
    <input type="button" value="Change Background Image" onclick="changeDivImage()" />
</center>

JavaScript

function changeDivImage() {
    var imgPath = new String();
    var div = document.getElementById("div1");
    imgPath = div.style.backgroundImage;
    alert('current background: ' + imgPath);


    div.style.backgroundImage = (imgPath.indexOf("blue.png") > -1 || imgPath == "") ? "url(green.png)" : "url(blue.png)";
}