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>

First
you need to disconnect the "ball" image from the document flow: using absolute positioning.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.