<!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>
js實(shí)現(xiàn)圖片慢慢移動(dòng)到指定位置后停止,左右移動(dòng)的看我代碼錯(cuò)哪里了?急求
木易老三
2017-06-20 14:07:16