<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/ecmascript">
function move(nTarget){
var oDiv=document.getElementById('div1');
if(nTarget>oDiv.offsetLeft){//向右走
oDiv.style.left=oDiv.offsetLeft+10+"px";
window.setTimeout("move("+nTarget+")",20);
}else if(nTarget<oDiv.offsetLeft){
oDiv.style.left=oDiv.offsetLeft-10+"px";
window.setTimeout("move("+nTarget+")",20);
}
}
</script>
</head>
<body>
<ul>
<li onclick="move(400);">1</li>
<li onclick="move(800);">2</li>
<li onclick="move(1200);">3</li>
</ul>
<div id="div1" style="width:100px; height:100px; background:yellow; position:absolute; top:110px; left:0;"></div>
</body>
</html>