JSFiddle - React, Tailwind, and code Playground

HTML

<div id="blinker"> Blinker </div>
<div id="button"> CLICK </div>

CSS

#blinker, #button {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 40px;
    color: black;
}
#blinker {
    left: 100px;
    background: yellow;
    width: 100px;
    text-align: center;
}

JavaScript

blinker = document.getElementById("blinker")

document.getElementById("button").onclick = function () {
  blink( blinker, 5 );
} 

function blink(node, flickers){

     var color = node.style.color;

    (function blinker(){
    
        node.style.color = (flickers % 2) ?  "red" : color;
        
        if (flickers--){

            setTimeout(blinker, 1000);
        }
    
    })();
 
}