これは私のJavascript関数です
<script type="text/javascript">
var foo = null; // object
function doMove() {
foo.style.left = parseInt(foo.style.left)+1+'px';
setTimeout(doMove,0); // call doMove in 20msec
document.getElementById("foo").innerHTML = foo.style.left;
if(foo.style.left=='100px'){
alert(foo.style.left);
}}
function init() {
foo = document.getElementById('foo'); // get the "foo" object
foo.style.left = '0px'; // set its initial position to 0px
doMove(); // start animating
}
window.onload = init;
</script>
<div id="foo" style="width:100px;background:#99ccff;position: relative;">I am moving box</div>