Ivankooo1

goshoTheKiller

Sep 14th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <img id="demo" src="IMG_2854.jpg" height="300" width="300">
  10. <button id ='btn' >Click me</button>
  11.  
  12. <script>
  13. document.querySelector("button").addEventListener('click',fn);
  14. let count = 0;
  15. function fn(e){
  16. let newPic = document.getElementById("demo");
  17.  
  18. let arr =["1335.jpg","IMG_2854.jpg"];
  19.  
  20. if(arr[count] === undefined){
  21. count = 0;
  22. }
  23. newPic.src = arr[count]
  24. count++;
  25.  
  26. // let pic;
  27. // switch(){
  28. // case 0:
  29. // pic = "IMG_2854.jpg";
  30. // break;
  31. // case 1:
  32. // pic = "1335.jpg";
  33. // break;
  34. // }
  35.  
  36.  
  37. }
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44. </script>
  45.  
  46.  
  47. </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment