I'm trying to create little slideshow using JS and JQuery. The code below works (sort of) but doesn't delay before showing the next image; just shows it right away. I'm trying to get it too delay for 5sec before showing the next image. I'm a bit of a novice so apologies if the code is dodgy.
*The URLs have been changed to make it more readable.
Thanks for helping!
var backgroundImg = ["https://x1.jpg", "https://x2.jpg"];
var backgroundImgLength = backgroundImg.length;
var z = 0;
do {
slideShow(backgroundImg[z]);
z++;
}
while (z < backgroundImgLength);
function slideShow(url) {
setTimeout(function() {
$('.header-section').css('background-image', 'url(' + url + ')');
}, 5000);
}