<html>
<head>
<title></title>
<script type="text/javascript">
function dianwo() {
var obj = document.getElementById('mydiv');
var x = obj.offsetLeft
var y = obj.offsetTop;
x += 10;
y += 10;
obj.style.left = x;
obj.style.top = y;
}
function show()
{
setInterval('dianwo()',500);
}
</script>
<style type="text/css">
.class1
{
width:100px;
height:100px;
background-color:Blue;
position:absolute; left:100px; top:100px;
}
</style>
</head>
<body>
<div id="mydiv" class="class1" ></div>
<input type="button" value="点我" οnclick="show();" />
</body>
</html>
js 实现图片自动移动
最新推荐文章于 2023-10-12 11:05:04 发布