P粉0374504672023-08-19 00:25:04
For a simple loop over an array, you can do this:
const array = ['a', 'b', 'c', 'd']; counter = 0; const interval = setInterval(() => { console.log(array[counter % array.length]); //例如 "a", "b" //你可以对返回值做任何操作(将其放入a标签中) counter++; }, 5000);
To clear the interval, you can do this:
clearInterval(interval);
I'm not sure what you want to do in the click event. Please provide further information.