關(guān)于obj.offsetWidth和obj.style.Width的區(qū)別
<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? 這兩個(gè)屬性有什么區(qū)別?
}
},30)
}
</script>
2016-01-04
JS中關(guān)于clientWidth offsetWidth scrollWidth 等的含義
上面鏈接中講解的很詳細(xì)