Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <body> <p>Cliquez sur le bouton et ajoutez un nouvel élément au tableau.</p> <button onclick="myFunction()">Cliquez</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>