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

js实现图片慢慢移动到指定位置后停止,左右移动的看我代码错哪里了?急求

js实现图片慢慢移动到指定位置后停止,左右移动的看我代码错哪里了?急求

木易老三 2017-06-20 14:07:16
<!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" xml:lang="en"><head>    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">    <title>Document</title></head><body>    <div id="box" style="width: 100px;height: 100px; background: blue;position:absolute;left:0;top:40px;"></div>        <button type="button" id="start">开始</button>        <script>        window.onload = function () {          var box = document.getElementById('box');          var start = document.getElementById('start');          var timer;        }         start.onclick = function () {            timer = setInterval(animFn, 50);          }                 function animFn () {            box.style.left = parseInt(box.style.left) + 5 + 'px';                        box.style.left = '100px';            window.clearInterval(timer);          }                              </script></body></html>
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 8415 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信