JSFiddle - React, Tailwind, and code Playground
HTML
<img id="image" src="http://www.o3mobi.com/jquery.jpg">
JavaScript
src1 = "http://www.o3mobi.com/jquery.jpg";
src2 = "http://www.bioneural.net/wp-content/uploads/2008/02/jquery.jpg";
$.fn.fadeToSrc = function(src, speedOut, speedIn, callback) {
return this.fadeOut(speedOut, function() {
$(this).attr('src', src).fadeIn(speedIn, callback);
});
};
$("#image").click(function () {
$("#image").fadeToSrc(src2, 1000, 4000);
});