当字符串处理了
比如
"1"+"1"
按你的意思应该是2
但是系统结果为11你把你的代码加个parseInt
cat.style.posLeft=parseInt(cat.style.posLeft)+parseInt(Math.random()*1.5);
cat.style.posTop=parseInt(cat.style.posTop)+parseInt(Math.random()*1.5);
比如
"1"+"1"
按你的意思应该是2
但是系统结果为11你把你的代码加个parseInt
cat.style.posLeft=parseInt(cat.style.posLeft)+parseInt(Math.random()*1.5);
cat.style.posTop=parseInt(cat.style.posTop)+parseInt(Math.random()*1.5);
function run()
{cat.style.posLeft=i;
cat.style.posTop=j;
i++;
j++;
setInterval("run()",100);
}
如果我把程序改成这样? 图片移动的时候也是移动的距离也是越来越大啊,这总不可能是当字符串处理了啊~~
(天外水火(我要多努力)),我按你的方法做了,可效果还是没变的,移动的距离越来越大!!!
我郁闷啊,郁闷!!!!!!!!!!!!!!!!!!
到底怎么回事哦??????????
var i=1,j=1;
function run()
{cat.style.posLeft+=i;
cat.style.posTop+=j;
setInterval("run()",100);
}