Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <body> <p>Cliquez sur le bouton pour ajouter des nouveaux éléments au début du 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.unshift("Black", "Green"); document.getElementById("demo").innerHTML = colors; } </script> </body> </html>