Program:
Output:
<html> <head> <script> var obj = null; var a ; function init() { obj=document.getElementById("car"); obj.style.position="relative"; obj.style.left="0px"; } function start() { obj.style.left=parseInt(obj.style.left)+10+"px"; a=setTimeout(start,20); } function stop() { clearTimeout(a); obj.style.left="0px"; } window.onload=init; </script> </head> <body> <img id="car" src="Logo.png"/> <input type="button" value="Start" onclick="start()"> <input type="button" value="Stop" onclick="stop()"> </body> </html>
Output: