speed=speed>0?Math.ceil(speed):Math.floor(speed); 向上取整沒有用
function?getStyle(obj,attr){
if(obj.currentStyle){
return?obj.currentStyle[attr];
}
else{
return?getComputedStyle(obj,null)[attr];
}
}
function?mover(){
var?box=document.getElementById("box");
box.timer=null;
box.onmouseover=function(){
star(box,"width",400);
}
box.onmouseout=function(){
star(box,"width",200);
}
}
function?star(obj,attr,target)
{
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var??who=obj.offsetWidth;
// who=parseInt(getStyle(obj,attr));
var?speed=(target-who)/8;
??speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(who==target)
{
clearInterval(obj.timer);
}
document.getElementById("id1").innerHTML=who;
document.getElementById("id2").innerHTML=speed;
obj.style[attr]=who+speed+"px";
},30);
}還是395 取整了也沒有 ? 代碼我一個個對了也沒問題 ? 在ie下 可以到達400沒有問題 ?谷歌下就不行?

2015-12-29
僅僅在搜狗試了下,可以。在谷歌沒試
2022-03-24
在好好的體會下。這里的加號是字符串拼接的意思