<!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>window.onload = function(){ var xiem = document.getElementById('xie'); xiem.onmousemove =function(){ startMove(); } xiem.onmouseout = function(){ startMOve1(); } }var time = null;function startMove(){ clearInterval(time); time = setInterval(function(){ var xiem = document.getElementById('xie'); if(xiem.offsetLeft== 0){ clearInterval(time); } else{ xiem.style.left=xiem.offsetLeft+10+'px'; } },30)}function startMove1(){ var time = null; clearInterval(time); time = setInterval(function(){ var xiem = document.getElementById('xie'); if(xiem.offsetLeft==-200){ clearInterval(time); } else{ xiem.style.left=xiem.offsetLeft-10+'px'; } },30)}</script><style type="text/css">*{margin:0; padding: 0;}#xie{width:230px; height:100px; background:#666; font-size:16px; position:relative; left:-200px;}</style></head><body><div id="xie"></div></body></html>
2 回答
已采纳
qq_大寒_2
TA贡献173条经验 获得超185个赞
window.onload = function(){ var xiem = document.getElementById('xie'); xiem.onmousemove =function(){ startMove(); } xiem.onmouseout = function(){ startMove1(); } }
startMOve1()=>startMove1(); 小写o
添加回答
举报
0/150
提交
取消