为了账号安全,请及时绑定邮箱和手机立即绑定

代码里面的Li1无法运行,调试找不到bug求各位大神帮助???

<!DOCTYPE html>

<!-- saved from url=(0089)file:///C:/Users/Administrator/Desktop/%E5%A4%9A%E7%89%A9%E4%BD%93%E5%8A%A8%E7%94%BB.html -->

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta charset="UTF-8">

<title>多物体动画</title>

<style type="text/css">

*{

margin: 0;

padding: 0;

}

ul,li{

list-style: none;

}

ul li{

width : 200px;

height: 100px;

background: #1E90FF;

margin-bottom: 20px;

border: 4px solid #000;

}

</style></head>


<body>

<script type="text/javascript">


window.onload=function(){

/*var oAl=document.getElementsByTagName('li');

for (var i = 0; i < oAl.length; i++) {


oAl[i].timer=null;

oAl[i].onmouseover=function(){

startMove(this,400);

}

oAl[i].onmouseout=function(){

startMove(this,200);

}*/

//var timer=null;

//var alpha=30;关键不能公用

var Li1=document.getElementById('li1');

Li1.onmouseover=function(){

startMove(this,'height',400);

}

Li1.onmouseover=function(){

startMove(this,'height',200);

}

var Li2=document.getElementById('li2');

Li2.onmouseover=function(){

startMove(this,'height',400);

}

Li2.onmouseout=function(){

startMove(this,'height',100);

}


function startMove(obj,attr,iTarget){

clearInterval(obj.timer);


obj.timer=setInterval(function(){

var speed=(iTarget-parseInt(getStyle(obj,attr)))/8;

speed=speed>0?Math.ceil(speed):Math.floor(speed);

if (parseInt(getStyle(obj,attr))==iTarget) {

clearInterval(obj.timer);

}else{

obj.style[attr]=parseInt(getStyle(obj,attr))+speed+'px';



}


},30)

}

};


function getStyle(obj,attr){

if (obj.currentStyle) {

return obj.currentStyle[attr];

}else{

return getComputedStyle(obj,false)[attr];


}


}

</script>

<ul>

<li id="li1"></li>

<li id="li2"></li>

<li id="li3"></li>

</ul>


</body></html>


正在回答

1 回答

Li1的onmouseout你写成onmouseover了,移开没有作用。

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

代码里面的Li1无法运行,调试找不到bug求各位大神帮助???

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信