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