I am taking an intro to javaScript/jQuery class and have to make a header slide show, I can't get it to work, could you please take a look and see what errors I might have made? I am hitting a dead end and it feels like I'm banging my head against a wall. it says I need to add more typing that isn't code, so i'm typing more here. Please feel free to ask any clarifying questions,
"use strict";
$(document).ready( () => {
let nextSlide = $("#slides img:first-child");
setInterval( () => {
$("#caption").fadeOut(2000);
$("#slide").fadeOut(2000,
() => {
if (nextSlide.next().length == 0) {
nextSlide = $("#slides img:first-child");
}
else {
nextSlide = nextSlide.next();
}
const nextSlideSource = nextSlide.attr("src");
const nextCaption = nextSlide.attr("alt");
$("#slide").attr("src", nextSlideSource).fadeIn(1000);
$("#caption").text(nextCaption).fadeIn(1000);
}); // end fadeOut()
},
1000); // end setInterval()
});
#slides img {
display: none;
}
#slide {
width: 100%;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>SlideShow</title>
<script src="https://code.jquery.com/jquery-3.6.0.slim.min.js"></script>
<script src="slide_show.js"></script>
</head>
<body>
<h2>Slide SlideShow</h2>
<header>
<h2 id="caption">Headers</h2>
<img id="slide" src="Images/Header/paintingone.jpg" alt="">
<div id="slides">
<img src="Images/Header/paintingone.jpg" alt="One">
<img src="Images/Header/paintingtwo.jpg" alt="Two">
<img src="Images/Header/paintingthree.jpg" alt="Three">
<img src="Images/Header/paintingfour.jpg" alt="Four">
</div>
</header>
<main>
</main>
</body>
</html>