Start New Discussion Reply to this Discussion Javascript animation
Hi there,,
I am trying to get my hea around this simple line of code and trying also to make it work. The ball doesn't move to any direction.. thanks for the help..
<script type="text/javascript">
function moveRight(){
document.images['ball'].style.left = parseInt(document.images['ball'].style.left)+5 +"px";
}
</script>
</head>
<body>
<img id="ball" src="ball.jpg" alt="ball bouncing" width="50px" height="50px"/> <br/>
<input type="button" onclick="javascript: var t = setInterval('moveRight()', 10);" value="move me">
</body>
rotten69
Master Poster
747 posts since May 2011
Reputation Points: 36
Solved Threads: 47
Skill Endorsements: 11
First
you need to disconnect the "ball" image from the document flow: using absolute positioning.
Troy III
Master Poster
741 posts since Jun 2008
Reputation Points: 140
Solved Threads: 95
Skill Endorsements: 5
© 2013 DaniWeb® LLC
Page rendered in 0.0554 seconds
using 2.65MB