<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Document</title><style>#div1{width:100px;height: 100px;position: absolute;background: red;left: 0;top: 50px;}</style><script> window.onload=function(){ function startMove(){ var oDiv = document.getElementById('div1'); setInterval (function(){ oDiv.style.left = oDiv.offsetLeft+10+'px'; },30); }}</script> </head><body><input type="button" value="开始运动" id="but" onclick="startMove()"/><div id="div1"></div></body></html>
添加回答
举报
0/150
提交
取消