JSFiddle - React, Tailwind, and code Playground
HTML
<div id="playlist">
<div class="playlist_item">Song 1</div>
<div class="playlist_item">Song 2</div>
<div class="playlist_item">Song 3</div>
<div class="playlist_item">Song 4</div>
<div class="playlist_item">Song 5</div>
<div class="playlist_item">Song 6</div>
<div class="playlist_item">Song 7</div>
<div class="playlist_item">Song 8</div>
</div>
CSS
#playlist .playlist_item {
background: #d6d6d6;
}
#playlist .playlist_item:nth-child(odd) {
background: #b3b3b3;
}
JavaScript
$('.playlist_item').click(
function() {
var $dv = $(this);
$dv.data('oldBG', $dv.css('backgroundColor'));
$dv.animate({backgroundColor: '#ff0000'}, 2000, function() {
$(this).css('backgroundColor', $(this).data('oldBG'));
});
});