let index = 1;
let images = [
'./img/wok.jpg',
'./img/croissant.jpg',
'./img/salad.jpg'
];
let img = document.getElementById("section-1-img");
let startButton = document.getElementById('startButton');
setInterval(function() {
img.src = images[index];
index = (index +1) % images.length;
if (img.src === './img/wok.jpg') {
startButton.href = 'recipe.html';
else if (img.src === './img/croissant.jpg') {
startButton.href = 'recipe-2.html';
else if (img.src === './img/salad.jpg') {
startButton.href = 'recipe-3.html';
} 2000);
I wish for the button's destination to change dynamically based on the image being displayed. So when I click on the button, it should direct me to the corresponding HTML page.