JSFiddle - React, Tailwind, and code Playground

HTML

<button id="btn1">CLICK ME</button>
<br>
<img id="blue" src="http://placehold.it/350x150&text=1">
<br>
<br>
<button>CLICK ME</button>
<br>
<img id="green" src="http://placehold.it/350x150&text=2">

JavaScript

(function ($) {
    $.fn.clickToggle = function (func1, func2) {
        var funcs = [func1, func2];
        this.data('toggleclicked', 0);
        this.click(function () {
            var data = $(this).data();
            var tc = data.toggleclicked;
            $.proxy(funcs[tc], this)();
            data.toggleclicked = (tc + 1) % 2;
        });
        return this;
    };
}(jQuery));


$("#btn1").clickToggle(function () {
    $("#blue").attr('src', 'http://placehold.it/350x150&text=2');
}, function () {
    $("#blue").attr('src', 'http://placehold.it/350x150&text=1');
});