做两个图片都移动的问题请教下!!
虽然都能动,但是不能同时动!!请哪位朋友指点下。sda<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
background-image: url(game.jpg);
}
-->
</style></head>
<body>
<script language="javascript">
function moveMan()
{
if(event.keyCode==38)
{
smallman.style.pixelTop=smallman.style.pixelTop-5;
}
else if(event.keyCode==40)
{
smallman.style.pixelTop=smallman.style.pixelTop+5;
}
else if(event.keyCode==37)
{
smallman.style.pixelLeft=smallman.style.pixelLeft-5;
}
else if(event.keyCode==39)
{
smallman.style.pixelLeft=smallman.style.pixelLeft+5;
}
else if(event.keyCode==87)
{
aman.style.pixelTop=aman.style.pixelTop-5;
}
else if(event.keyCode==83)
{
aman.style.pixelTop=aman.style.pixelTop+5;
}
else if(event.keyCode==65)
{
aman.style.pixelLeft=aman.style.pixelLeft-5;
}
else if(event.keyCode==68)
{
aman.style.pixelLeft=aman.style.pixelLeft+5;
}
}
document.onkeydown=moveMan;
</script>
<div id="smallman" style="position:absolute; left: 468px; top: 90px;"><img src="man.gif" /></div>
<div id="aman" style="position:absolute; left: 560px; top: 350px;"><img src="aman.jpg" /></div>
</body>
</html>