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

这个变化函数哪里出问题了?

这个变化函数哪里出问题了?

慕妹3146593 2019-04-19 15:15:48
<!DOCTYPE html><html><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <meta http-equiv="X-UA-Compatible" content="ie=edge">    <title>多物体运动框架</title>    <style>    #div1 {        width: 100px;        height: 50px;        background-color: red;        margin-top:50px;    }     </style>        <script type="text/javascript">                                                window.onload=function()        {            var oDiv = document.getElementById('div1');            oDiv.onmouseover=function()            {                startMove(300);            }            oDiv.onmouseout=function()            {                startMove(100);            }            }        var timer = null;        function startMove(iTarget)//这个函数        {                var oDiv = document.getElementById('div1');                clearInterval(timer);                timer=setInterval(function () {                    var iSpeed = (iTarget - oDiv.offsetwidth)/8;                    iSpeed=iSpeed>0?Math.ceil(iSpeed):Math.floor(iSpeed);                    if(oDiv.offsetWidth == iTarget)                    {                        clearInterval(timer);                    }                    else                    {                        oDiv.style.width = oDiv.offsetWidth + iSpeed + 'px';                    }                },30)        }        </script></head><body>    <div id="div1"></div></body></html>
查看完整描述

2 回答

?
慕后森

TA贡献1802条经验 获得超5个赞

var iSpeed = (iTarget - oDiv.offsetwidth)/8;

这一行 那个 offsetWidth

w没有大写


查看完整回答
反对 回复 2019-05-12
?
收到一只叮咚

TA贡献1821条经验 获得超5个赞

F12 设置断点 调试你就知道


查看完整回答
反对 回复 2019-05-12
  • 2 回答
  • 0 关注
  • 375 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号