setInterval() and clearInterval() Example

var t;
 
function show_uploaded_logo() {
   if($('div.form-item div.image-widget div.image-preview img').is('*'))
   {
      // use console.log to test that the function has stopped running
      //console.log('running');
      if(!$('img#step-1-preview-image').is('*'))
      {
            //code here
      }
      else
      {
           clearInterval(t);	
      }
 
   }   
}
 
t = setInterval(show_uploaded_logo,1000);