为了账号安全,请及时绑定邮箱和手机立即绑定

为什么鼠标移动到方块上不会移动

<!doctype html>

<html>

  <head>

    <meta charset="UTF-8">

    <title>缓冲动画</title>

<style type="text/css">

div body{

 margingin:0;

 padding:0;

}

 #div1{

   width:250px;

height:200px;

background:red;

position:relative;top:0px;left:-200px;

 }

</style>

<script>

 window.onload=function{

   oDiv = document.getElementById("div1");

oDiv.onmouseover = function(){

 startMove(0);

}

oDiv.onmouseout = function(){

 startMoove(-200); 

}


 }

 var timer = null;

 function startMove(iTarget){

   clearInterval(timer);

   var oDiv = document.getElementById("div1");

timer = setInterval(function(

 var speed = 0;

 if(odiv.offsetLeft > iTarget){

   speed = -10;

 }else{

   speed = 10;

 }

 if(oDiv.offsetLeft == iTarget){

   clearInterval(timer);

 }else{

   oDiv.style.left = oDiv.offsetLeft+speed+"px";

 }

),30);

 }

</script>

  </head>

  <body>

    <div id="div1"></div>

  </body>

</html>


正在回答

2 回答

因为Java中字符串常量管理有特殊机制,所以不同对象指向同一个常量使用“==”比较结果为true

jbymfnidblazloefvr

0 回复 有任何疑惑可以回复我~

都不知道怎么回答好,你代码写错了,window.onload=function(){}

timer = setInterval(function(){});

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为什么鼠标移动到方块上不会移动

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信