zeshan-a
8/24/2016 - 4:54 AM

Run a function multiple times until the element is found on the page

Run a function multiple times until the element is found on the page

function runUACLCLoop() {

	setTimeout(function() {

		// Check if something is found on the page. 
		if ( jQuery('.class_name').is(':visible') ) { // change it to another condition
      // Run the same function again to create the loop.
			runUACLCLoop(); 
		
		// If nothing is found, then run the else statement.
		} else {
			setTimeout(function () {
				// Do other great stuff here....
			}, 500);
		}

	}, 200);

}