關于javascript的settimeout函數的問題,我遞歸調用做動畫,但是卻瞬間到達!為什么!??!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 關注
- 600 瀏覽
添加回答
舉報
0/150
提交
取消