My goal is to achieve a dynamic effect where the background color pulsates when a specific condition is met. Currently, I have the following code:
<div class="box">...</div>
.box {
background-color: #fff;
transition: background-color 0.5s ease-out;
}
.box.active {
background-color: #ccc;
}
Now, I want to utilize jQuery to add and remove the 'active' class multiple times in order to create a pulsating background color effect. Here's what I tried:
$('.box').addClass('active').delay(1000).removeClass('active').delay(1000).addClass('active');
In theory, this approach should generate the desired pulsating effect. However, in practice, the 'active' class seems to be added but not removed or added again. It appears as though the first 'removeClass' call is not being triggered.
I believe there may be something missing in my implementation, but I'm unsure of what it might be. Could it be related to CSS transition timing? Despite being separate components, they should work independently, correct?
If you have any insights or ideas, I would greatly appreciate them. Thank you!