<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>练习</title>
<style>
div{
width:100px ;
height: 30px;
background: red;
margin: 10px;
}
</style>
<script>
window.onload=function (ev) {
var oDiv=document.getElementsByTagName("div");
for (var i=0;i<oDiv.length;i++){
oDiv[i].timer=null;
oDiv[i].onmouseover=function () {
startMove(this,400);
};
oDiv[i].onmouseout=function () {
startMove(this,100);
}
}
};
function startMove(obj,iTarget) {
clearInterval(obj.timer);
obj.timer=setInterval(function () {
var sp
javascript 多个div同时移动
最新推荐文章于 2023-08-18 11:59:45 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)