JSFiddle - React, Tailwind, and code Playground

HTML

<div class="test">
<a href="test1.html">link 1</a>
<a href="test2.html">link 2</a>
<a href="test3.html">link 3</a>
</div>

CSS

.selected{
  color: green;  
}

JavaScript

$('.test a').click(function(){
    
    // select the object that was clicked on
    $(this)
        // add the selected class to it
        .addClass('selected')
        // remove the selected class from it's brothers and sisters
        .siblings().removeClass('selected')
        
    // stop link from loading and resetting page
    return false
        
})