I need a jQuery color animation without CSS3 functions.
I coded this:
function button_selection() {
setTimeout(button_selection, 800);
setTimeout(function () { $(".color").css("color", "yellow"); }, 200);
setTimeout(function () { $(".color").css("color", "blue"); }, 400);
setTimeout(function () { $(".color").css("color", "red"); }, 600);
setTimeout(function () { $(".color").css("color", "green"); }, 800);
}
setTimeout(button_selection, 0);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h1 class="color">Hello world, I love you all.</h1>
In my browser, it works. But I think that the code is not really "good". How would it be possible to write the colors in one line and then just control the speed?
Thanks.