Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <body> <p>Klicken Sie auf den Button, um ein neues Element zum Array 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.push("Green"); document.getElementById("demo").innerHTML = colors; } </script> </body> </html>