JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
<a href="#one">link 1</a>
<a href="#two">link 2</a>
<a href="#three">link 3</a>
<div id="one">
div one
</div>
<div id="two">
div two
</div>
<div id="three">
div three
</div>
CSS
.active {color: red;}
JavaScript
$(document).ready(function() {
function addClass() {
var id = $(this).attr('href');
$("a").removeClass('active');
$("div").removeClass('active');
$(this).addClass('active');
$(id).addClass('active');
}
var nodeList = document.querySelectorAll('a');
for( var i = 0; i < nodeList.length; i++) {
nodeList[i].addEventListener('click', addClass);
}
});