求大神解答。。。實(shí)在不知道錯(cuò)哪里了。。哭了
?<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{margin:0;padding: 0}
ul li{width: 200px;height: 100px;background-color: red;margin-bottom: 10px;border: 4px solid #000}
ul li{list-style: none;}
</style>
</head>
<body>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</body>
<script type="text/javascript">
window.onload=function(){
var aLi=document.getElementsByTagName('li');
for(var i=0;i<aLi.length;i++){
aLi[i].timer=null;
aLi[i].onmouseover=function(){
moveto(this,400);//讓寬到300
}
aLi[i].onmouseout=function(){
moveto(this,200);
}
}
}
function getStyle(obj,style){
? if(obj.currentStyle){
? ? return obj.currentStyle[style];
? ? }
? else{
? ? return getComputedStyle(obj,false)[style];
? ? }
}
function moveto(obj,itarget){
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var icur=parseInt(getStyle(obj,'width'));
var speed=(itarget-icur)/8;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(icur==itarget){
clearInterval(obj.timer);
}
else{
obj.style.width=icur+speed+'px'
//console.log(icur+' ,'+speed+' ,'+obj.style.width);
}
},30)
}
</script>
</html>
2016-04-20
沒(méi)有問(wèn)題,我自己的問(wèn)題。。。瀏覽器縮放了。。謝謝大家了。。不知道誰(shuí)動(dòng)我電腦了
2016-04-20
有一句沒(méi)有加分號(hào)obj.style.width=icur+speed+'px',只是看了一下,沒(méi)有運(yùn)行
2016-04-19
哪里有問(wèn)題?沒(méi)看出來(lái)啊
2016-04-16
出現(xiàn)了什么問(wèn)題???