javascript set timout code example
Example 1: javascript settimeout
setTimeout(function(){
alert("Sup!");
}, 2000);//wait 2 seconds
Example 2: js settimeout
setTimeout(() => { alert('Hello') }, 1000)
Example 3: add set time out in jquery
$(".submit_wide").click(function () {
$(this).val('Please wait..');
$(this).attr('disabled', true);
setTimeout(function() {
$(this).attr('disabled', false);
$(this).val('Submit');
}, 2000);
});
Example 4: js after settimeout
function doHomeWork(subject, callback){
setTimeout(callback,500);
console.log("doing my homework:", subject)
}
doHomeWork("Maths", function(){console.log("finished my homework");});