I wonder if anyone could help me with this simple DHTML movement question. I am trying to get my ball to go right then left in a smooth manner. I can get it to go right fine, but it jerks back to the left. I have tried all sorts of variables but it doesn't seem to want to work. The code is this:
<html>
<head>
<script language = "javascript">
dir = 0
function move() {
if(dir == 0) {
ball.style.pixelLeft +=3
if(ball.style.pixelLeft>=400)
ball.style.pixelLeft =-3
}
else if(ball.style.pixelLeft<20) {
ball.style.pixelLeft +=3}
setTimeout("move()", 30)
}
</script>
</head>
<body onload="move()">
<img src = "ball.jpg" style="position: absolute; left: 30px; width: 100px; height: 100px" id="ball">
</body>
</html>
give me your advice please
Web Designing Companies in Delhi |
Wedding Planners in Delhi |
Event Management Companies in Delhi