CODE

HTML

<div class="loading">
    <span class="load-ball"></span>
    <span class="load-ball"></span>
    <span class="load-ball"></span>
</div>

CSS

.loading{
    display: flex;
    gap: 20px;
}

.load-ball{
    content: '';
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #3db90c;
    
}

.loading span{
    animation: bounce .6s cubic-bezier(0.6,0,1,0.4);
    animation-iteration-count: infinite;
    animation-direction: alternate;
}

.loading span:nth-child(1){
    animation-delay: .1s;
}
.loading span:nth-child(2){
    animation-delay: .2s;
}
.loading span:nth-child(3){
    animation-delay: .3s;
}

.loading span:nth-child(1).changeColor{
    background-color: rgb(255, 0, 0);
}
.loading span:nth-child(2).changeColor{
    background-color: rgb(255, 0, 0);
}
.loading span:nth-child(3).changeColor{
    background-color: rgb(255, 0, 0);
}

@keyframes bounce {
    to{
        transform: translateY(30px);
    }
}

JAVASCRIPT

let count = 0;

function switchColor(){
    count++;
    
    if(count <=3){
        const ball = document.querySelector('.loading span:nth-child('+count+')');
        ball.classList.toggle('changeColor');

        if(count == 3){
            count = 0;
        }
    }
}

setInterval(switchColor, 500);