关于obj.offsetWidth和obj.style.Width的区别
<script type="text/javascript">
window.onload=function(){
aLi=document.getElementsByTagName('li');
for(var i=0,leg=aLi.length;i<leg;i++){
aLi[i].timer=null;
aLi[i].onmouseover=function(){
startMove(this,800);
}
aLi[i].onmouseout=function(){
startMove(this,200);
}
}
}
function startMove(obj,oTarget){
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var speed=(oTarget-obj.offsetWidth)/3;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(oTarget==obj.offsetWidth){
clearInterval(obj.timer);
}else{
obj.style.width=obj.offsetWidth+speed+'px';//为什么这里不能用obj.style.width? 这两个属性有什么区别?
}
},30)
}
</script>