Advertisement
here2share

Array Cycle Demo

Feb 15th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!doctype html>
  2. <html>
  3.  
  4. <head>
  5.     <title>Array Cycle Demo</title>
  6. </head>
  7.  
  8. <body>
  9.  
  10. <script type="text/javascript">
  11.  
  12. var links = [
  13. 'Start Of List',
  14. 'ABC',
  15. 123,
  16. 'XYZ',
  17. 'End Of List'
  18. ]
  19. var clicks = 0;
  20. function onClick() {
  21.     clicks = clicks % links.length;
  22.     document.getElementById("clicks").innerHTML = links[clicks];
  23.     clicks += 1;
  24. };
  25. </script>
  26. <button type="button" onClick="onClick()">Click Me</button>
  27. <p>Array Element: <a id="clicks">***</a></p>
  28.  
  29. </body>
  30.  
  31. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement