0
如何獲取移動的時間並保存它的值。所以每次有人點擊它,它只是增加了移動圖像,顯示值並保存當前值
var imgObj = null;
function init(){
imgObj = document.getElementById('myImage');
imgObj.style.position= 'relative';
imgObj.style.left = '0px';
}
function moveRight(){
if(parseInt(imgObj.style.left) < 700){
imgObj.style.left = parseInt(imgObj.style.left) + 10 + 'px';
}
if(parseInt(imgObj.style.left) == 700){
imgObj.style.left = parseInt(imgObj.style.left) + 0 + 'px';
}
}
window.onload =init;
問題不明確 –