javascript setInterval & clearInterval
An example to demonstrate how start interval & stop it using javascript.
var x = window.setInterval(
function(greeting, name){
var m = document.createElement("div");
with(m.style){
height = "2px";
width = "50px";
position = "relative";
backgroundColor= "green";
}
document.body.appendChild(m);
},
1000,
"hello",
"world",
document.body.onclick = function(){
clearInterval(x)
}
);
Tags: Javascript
You can comment below, or link to this permanent URL from your own site.
May 29, 2009 at 8:12 am
cool, post some more if possible!!! i forgot java now.
May 29, 2009 at 8:16 am
more posts going to come soon.
By the way, that’s Javascript, not Java