Hello, tell me how to make the button color blink, otherwise my current will blink once and stop.

$(function () { $("#Button").css("color", "black"); setTimeout(function () { $("#Button").css("color", "black"); setInterval(function () { $("#Button").css("color", "green"); }, 500) }, 3000); }); 

-

 <a id="Button" href="#"></a> 

    2 answers 2

    In my opinion, you have a bust with functions, but I will leave it as it is, and here is my option:

     $(function () { var flag = false; $("#Button").css("color", "black"); setTimeout(function () { $("#Button").css("color", "black"); setInterval(function () { $("#Button").css("color", flag? "black":"green"); flag = !flag; }, 500) }, 3000); }); 
    • Yes, thanks earned! - Sergey_666
     function startcolor { var coloring = true while(coloring = true) { $("#Button").css("color", "black"); setTimeout(function () { $("#Button").css("color", "black"); setInterval(function () { $("#Button").css("color", "green"); }, 500) }, 3000); } } function stopColor() { coloring = false; } 

    The start of the blink is caused by the startColor () command, and the end of the stopColor ()

    • It turns out that an infinite loop - Sergey_666
    • @ Сергей_666 Yeah, that stops the stopColor () function. And if you want him to not interfere with anyone, let him through web workers - kandi
    • Only when the first function is launched, the browser restarts, and the second function does not get to it - Sergey_666