我试图从右侧移到一个img左的Javascript搬东西
但是代码只从左至右
这部作品是左到右一个这一个工程
为例<script language="javascript">
var x = 310; //Starting Location - left
var dest_x = 300; //Ending Location - left
var interval = 2; //Move 10px every initialization
function moveImage() {
//Keep on moving the image till the target is achieved
if(x<dest_x) x = x + interval;
//Move the image to the new location
document.getElementById("ufo").style.left = x+'px';
if ((x+interval < dest_x)) {
//Keep on calling this function every 100 microsecond
// till the target location is reached
window.setTimeout('moveImage()',10);
}
有人知道这个问题吗?真的很感激它!
尝试使间隔为负值,或将其从x中不加入。你现在开始在310和每个循环加2,所以你不会下降到300 – Dampsquid 2012-03-12 23:21:17