關(guān)于javascript的settimeout函數(shù)的問題,我遞歸調(diào)用做動畫,但是卻瞬間到達(dá)!為什么!??!function moveElemet(tarElemet,position){var count = parseInt(tarElemet.style.marginLeft);if (count < position){ // on the left, move right count+=1;alert(count);tarElemet.style.marginLeft=count+"px";setTimeout ( moveElemet( tarElemet,position) ,1000);}就是把tarElemet往右移動,用settimeout的1000ms延遲做出動畫效果,但是它卻是瞬間把marginLeft值改變成position值了,是忽略了settimeout的delay屬性嗎?求高手指教?。。。。。。。。?!
- 3 回答
- 0 關(guān)注
- 601 瀏覽
添加回答
舉報(bào)
0/150
提交
取消