setTimeout and setInterval JavaScript Demo

In these demos, after some seconds of delay, the scripts insert a word in this page.

setTimeout with a function:

function a()
{
var e = document.getElementById("storage1");
e.innerHTML = "<b style='font-size:100%'>Hello!</b>";
}
setTimeout(a, 2500);

 

setTimeout with an expression:

setTimeout("document.getElementById('storage2').innerHTML=
\"<b style=\'font-size:100%\'>Hello!</b>\"", 4000);

 

setInterval with a lambda (anonymous) function:

var x = setInterval(function(){
document.getElementById('storage3').innerHTML+="<b>Beep</b><br>";
}, 1000);

 


Back to the tutorial setTimeout and setInterval.