I am trying to achieve an effect in which the background color pulsates when this condition me. Therefore, I have:
<div class="box">...</div>
.box {
background-color: #fff;
transition: background-color 0.5s ease-out;
}
.box.active {
background-color: #ccc;
}
So now I want to use jQuery to add and remove this class a couple of times to create a ripple effect of the background color. Sort of:
$('.box').addClass('active').delay(1000).removeClass('active').delay(1000).addClass('active');
This, in theory, should create a pulsating effect, but it is not. It happens that the "active" class is added and never deleted or never added again. It's almost like the first "removeClass" never fires.
Something is missing me, but I don’t know what. Maybe this has something to do with CSS transition time, but they should be independent of each other, right?
Thanks for any ideas.
source
share