For example, I have 5 buttons and I have a time of 10 seconds. I'm trying to play animations behind each button, starting from the 1st button, for 2 seconds each. But as I tried below, after playing the animations in sequence, it gets mixed up and the animations of the buttons play randomly. Below are the codes I have tried.
I have one function as follows, and when the time is up, I enter this function and process it.sorry i am new to javascipt i tried this way.Exactly what I want:The animation of the 1st button will play for 2 seconds and it will switch to the animation of the 2nd button, it will play for 2 seconds and will switch to the animation of the 3rd button. So in order
function reset() {
document.getElementById("1").style.animation = "glowing 500ms infinite";
setTimeout(function () {
document.getElementById("1").style.animation = "none";
}, 500);
setTimeout(function () {
document.getElementById("2").style.animation = "glowing 500ms infinite";
}, 500);
setTimeout(function () {
document.getElementById("2").style.animation = "none";
}, 1000);
setTimeout(function () {
document.getElementById("3").style.animation = "glowing 500ms infinite";
}, 1000);
setTimeout(function () {
document.getElementById("3").style.animation = "none";
}, 1500);
setTimeout(function () {
document.getElementById("4").style.animation = "glowing 500ms infinite";
}, 1500);
setTimeout(function () {
document.getElementById("4").style.animation = "none";
}, 2000);
setTimeout(function () {
document.getElementById("5").style.animation = "glowing 500ms infinite";
}, 2000);
setTimeout(function () {
document.getElementById("5").style.animation = "none";
}, 2500);
}