Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <p>Click the button to add elements to the array.</p>
  6.  
  7. <button onclick="myFunction()">Try it</button>
  8.  
  9. <p id="demo"></p>
  10.  
  11. <script>
  12. var fruits = ["Banana", "Orange", "Apple", "Mango"];
  13. document.getElementById("demo").innerHTML = fruits;
  14.  
  15. function myFunction() {
  16. fruits.splice(2, 0, "Lemon", "Kiwi");
  17. document.getElementById("demo").innerHTML = fruits;
  18. }
  19. </script>
  20.  
  21. </body>
  22. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement