We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,285 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
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>
2
Contributors
1
Reply
3 Days
Discussion Span
9 Months Ago
Last Updated
2
Views
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

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0554 seconds using 2.65MB