Advertisement
gitman3

Untitled

Apr 22nd, 2024
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <!-- 7. Implement a jQuery script to create a simple slideshow that automatically cycles through images stored in an array. -->
  2. <!DOCTYPE html>
  3. <html lang="en">
  4.  
  5. <head>
  6. <meta charset="UTF-8">
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <script src="https://code.jquery.com/jquery-3.7.1.min.js"
  9. integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
  10. <title>Document</title>
  11. </head>
  12.  
  13. <body style="background-image: url();">
  14. <script>
  15. $(document).ready(function () {
  16. const arr = ["./images/img1.jpg", "./images/img2.jpg", "./images/img3.jpg", "./images/img4.jpg", "./images/img5.jpg"];
  17. let i = 0, intv = 2000;
  18. function changeBg() {
  19. $('#imageChng').attr("src", arr[i]);
  20. i = (i + 1) % arr.length;
  21. }
  22. changeBg();
  23. setInterval(changeBg, intv);
  24. });
  25.  
  26. </script>
  27. <img src="" id="imageChng" style="height: 100vh; width: 100vw;">
  28. </body>
  29.  
  30. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement