b_hole
10-31-2006, 12:37 PM
Hi all,
I'm trying to use setInterval to make a movement effect for a div. Here's the code:
onload=function() {
nowIDheight=document.getElementById("t").style.height;
nowIDheight=nowIDheight.substr(0, nowIDheight.length-2); //to remove px
for (i=0; i<=100; i++)
setInterval(function(){document.getElementById("t").style.height=i+"px"}, 1000);
}
...
<div style="height: 100px;border: 1px solid red" id="t">bla</div>
But that doesn't do the trick.
What's wrong here?
I'm trying to use setInterval to make a movement effect for a div. Here's the code:
onload=function() {
nowIDheight=document.getElementById("t").style.height;
nowIDheight=nowIDheight.substr(0, nowIDheight.length-2); //to remove px
for (i=0; i<=100; i++)
setInterval(function(){document.getElementById("t").style.height=i+"px"}, 1000);
}
...
<div style="height: 100px;border: 1px solid red" id="t">bla</div>
But that doesn't do the trick.
What's wrong here?