JSFiddle - React, Tailwind, and code Playground

HTML

<button type="button">change source</button> 
<img id="check" src="http://www.vectordiary.com/isd_premium/042-clown-fish/clown-fish-illustration.jpg">

JavaScript

var check_img=$("#check");
var current_src=check_img.attr("src");
var other_src="http://www.petguide.com/wp-content/uploads/2013/11/glass-fish-1.jpg";


window.setInterval(function(){
    new_src=check_img.attr("src");
    if(current_src!=new_src){
        alert("interval function noticed a source change!");
        other_src=current_src;
        current_src=new_src;
    }

}, 500);

$('button').on('click', function(){

    check_img.attr("src", other_src);

});