JavaScript Program for Moving Car Animation

Write a JavaScript program for moving car animation.



Source Code
<html>
<head>
    <title>Moving car animation</title>
    <script type="text/javaScript">
        var t;
        var pos = 0;
        function init()
        {
            t = setInterval('moveCar()', 100);
        }
        function moveCar()
        {
            var car = document.getElementById('car');
            pos += 10;
            car.style.left = pos + 'px';
        }
        function stopCar()
        {
            clearTimeout(t);
            pos = 0;
            car.style.left = pos + 'px';
            car.style.right = pos + 'px'
        }
    </script>
</head>
<body>
<img id="car" src="images/car.png" width="150" height="100" style="position: absolute; left: 0px; top: 0px;"></img>
<input type="button" value="Start" onclick="init()" style="position: absolute; top:150px;"/>
<input type="button" value="Stop" onclick="stopCar()" style="position: absolute; top:150px; left: 70px;"/>
</body>
</html>
Output