I have written this code : it suppose to move an image down :
CODE
<body onload="test()">
<script type="text/javascript">
function test()
{
var ii = 1;
while(ii < 100)
{
setTimeout(function(){move_it(ii);}, ii*100);
ii = ii + 10;
}
}
function move_it(x)
{document.getElementById('move').style.top = x+'px';alert(document.getElementById('move').style.top);}
</script>
<img id="move" style="position:absolute;top:1px" src="image.gif" />
</body>
<script type="text/javascript">
function test()
{
var ii = 1;
while(ii < 100)
{
setTimeout(function(){move_it(ii);}, ii*100);
ii = ii + 10;
}
}
function move_it(x)
{document.getElementById('move').style.top = x+'px';alert(document.getElementById('move').style.top);}
</script>
<img id="move" style="position:absolute;top:1px" src="image.gif" />
</body>
I put the alert part to see how it changes each time, but it keep saying "101px" ;
I did the alert with the x : alert(x), and it showed "101" . why my x variable is 101 ?
Thanks
