JSFiddle - React, Tailwind, and code Playground
by salman
HTML
<a class="my_list" href="#">aaa</a><br>
<a class="my_list" href="#">aaa</a><br>
<a class="my_list" href="#">aaa</a><br>
<a class="my_list" href="#">aaa</a><br>
<a class="my_list" href="#">aaa</a><br>
JavaScript
$('.my_list').click(function () {
var selected_object = $(this);
$('.my_list').each(function () {
var current_object = $(this);
if (selected_object.is(current_object)) {
current_object.css({
color: "white"
});
}
if (selected_object.get(0) == current_object.get(0)) {
current_object.css({
background: "red"
});
}
});
});