<html> <button onclick="runter()">runter</button> <img id="ball" width=50 height=50 style="position: absolute; left: 100; top: 50" src="https://cdn.shopify.com/s/files/1/0906/5342/products/NickLight_SoccerBall1.jpg?v=1497386076"> <button onclick="hoch()">hoch</button> <button onclick="rechts()">rechts</button> <button onclick="left()">links</button> </img> <script> y = 50 x=100 function runter() { y = y + 10 document.getElementById("ball").style = "position: absolute; left: "+x+"; top: "+y } function hoch() { y=y - 10 document.getElementById("ball").style = "position: absolute; left: "+x+"; top: "+y } function rechts() { x=x + 10 document.getElementById("ball").style = "position: absolute; left: "+x+"; top: "+y } function left() { x=x - 10 document.getElementById("ball").style = "position: absolute; left: "+x+"; top: "+y } </script> </html>
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more