DOM編程藝術(shù)中的小問題,不是特別理解,求解答

科技 未結(jié) 10 1291

function moveElement( elementID , final_x , final_y, interval ) { if ( !document.getElementById ) return false; if ( !document.getElementById(elementID) ) return false; var elem = document.getElementById(elementID); var xpos = parseInt(elem.style.left); var ypos = parseInt(elem.style.top); if (xpos == final_x && ypos == final_y) {} if (xpos < final_x) { xpos++; } if (xpos > final_x) { xpos--; } if (ypos < final_y) { ypos++; } if (ypos > final_y) { ypos--; } elem.style.left = xpos + "px"; elem.style.top = ypos + "px"; var repeat = "moveElement(+elementID+,"+final_x+","+final_y+","+interval+")"; movement = setTimeout(repeat,interval); }

其中:var repeat = "moveElement(+elementID+,"+final_x+","+final_y+","+interval+")";的+elementID+前面的加號和+interval+后面的加號的作用是什么呢?

10條回答
提交回復