<html>
<head>
<script type="text/javascript">
function move(event){
var e = event.keyCode;
var d = document.getElementById("ig");
if(e == 37){//左
d.style.right = parseInt(d.style.right) + 20;
}else if(e == 38){//上
d.style.top = parseInt(d.style.top) - 20;
}else if(e == 39){//右
d.style.right = parseInt(d.style.right) - 20;
}else if(e == 40){//下
d.style.top = parseInt(d.style.top) + 20;
}
}
</script>
</head>
<body onKeyDown="move(event)">
<div id="ig" style="position:absolute;right:100;top:100">
<img src=" http://img.baidu.com/img/img-jg.gif" alt="走路" height="50px" width="50px"/>
</div>
</body>
</html>
<head>
<script type="text/javascript">
function move(event){
var e = event.keyCode;
var d = document.getElementById("ig");
if(e == 37){//左
d.style.right = parseInt(d.style.right) + 20;
}else if(e == 38){//上
d.style.top = parseInt(d.style.top) - 20;
}else if(e == 39){//右
d.style.right = parseInt(d.style.right) - 20;
}else if(e == 40){//下
d.style.top = parseInt(d.style.top) + 20;
}
}
</script>
</head>
<body onKeyDown="move(event)">
<div id="ig" style="position:absolute;right:100;top:100">
<img src=" http://img.baidu.com/img/img-jg.gif" alt="走路" height="50px" width="50px"/>
</div>
</body>
</html>