javascript用setinterval实现图片不停往右移动应该怎么写?
1个回答
展开全部
<script type="text/javascript">
function move(){
var oDiv = document.getElementById('moveItem');
var nextLeft = parseInt(oDiv.style.left) +10;
oDiv.style.left = nextLeft+'px';
}
function startMove(){
handler = setInterval(move,10);
}
</script>
<body onload="startMove()">
<div id="moveItem" style="position:absolute; left:400px; top:200px" ><img src=""/></div>
function move(){
var oDiv = document.getElementById('moveItem');
var nextLeft = parseInt(oDiv.style.left) +10;
oDiv.style.left = nextLeft+'px';
}
function startMove(){
handler = setInterval(move,10);
}
</script>
<body onload="startMove()">
<div id="moveItem" style="position:absolute; left:400px; top:200px" ><img src=""/></div>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询