<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Move Game</title>
<link rel="stylesheet" type="text/css" href="style/MoveOne.css">
</head>
<body>
<div id="box">
<span>Cion</span>
</div>
<script src="js/Movefirst.js"></script>
</body>
</html>
window.onload=Move;
function Move(){
var box=document.getElementById("box");
box.onmouseover=function (){
MoveBegin();
}
box.onmouseout=function(){
MoveStop();
}
}
function MoveBegin(){
var timer=null;
clearInterval(timer);
var box=document.getElementById("box");
timer=setInterval(function(){
if (box.offsetLeft==0) {
clearInterval(timer);
}else{
box.style.left=box.offsetLeft+1+"px";
}
},30);
}
function MoveStop(){
var timer=null;
var box=document.getElementById("box");
clearInterval(timer);
timer=setInterval(function(){
if (box.offsetLeft==-400) {
clearInterval(timer);
}else{
box.style.left=box.offsetLeft-1+"px";
}
},30);
}慕娘5227020
甫里
相关分类