Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <body> <p>Klicken Sie auf den Button, um Elemente am Anfang des Arrays hinzuzufügen.</p> <button onclick="myFunction()">Click</button> <p id="demo"></p> <script> var colors = ["Orange", "Red", "Blue"]; document.getElementById("demo").innerHTML = colors; function myFunction() { colors.unshift("Black", "Green"); document.getElementById("demo").innerHTML = colors; } </script> </body> </html>