JSFiddle - React, Tailwind, and code Playground

HTML

<div id="divs">
    <div>First</div>
    <div class="selected">Second</div>
    <div>Third</div>
    <div>Fourth</div>
</div>

<p id="output"></p>

CSS

#divs { overflow:auto; cursor:default; }
#divs div { float:left; margin:5px; border:1px solid gray; background-color:#ccc; width:100px; height:100px; }
#divs div.selected { border:1px solid red; background-color:#faa; }

JavaScript

var divs = $('#divs > div'),
    output = $('#output'),
    tarr = [0, 0, 0, 0],
    delay = 100;

divs.click(function() {
    $(this).addClass('selected').siblings().removeClass('selected');
});

setInterval(function() {
    var idx = divs.filter('.selected').index();
    tarr[idx] = tarr[idx] + delay;
    output.text('Times (in ms): ' + tarr);
}, delay);