<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>js运动基础</title>
<style>
#div1{ width:200px; height:200px; background:yellow; position:absolute; top:50px; left:0;}
</style>
<script>
function startMove()
{
var oDiv=document.getElementById('div1');
setInterval(function ()
{
oDiv.style.left=oDiv.offsetLeft+10+'px';
},30);
}
</script>
</head>
<body>
<input type="button" id="btn" value="开始运动" οnclick="startMove()" />
<div id="div1"></div>
</body>
</html>
js运动基础
最新推荐文章于 2021-06-28 15:58:06 发布