JSFiddle - React, Tailwind, and code Playground

by Cale Bergh

HTML

<div id="Space">
  <ul>
    <li role="presentation" class="sort">
      <a class="link" href="#" style="text-decoration:none;">인기순</a>
    </li>
    <li role="presentation" class="date">
      <a class="link" href="#" style="text-decoration:none;">최신순</a>
    </li>
  </ul>
</div>

CSS

a.link.active {
  color: red;
}

a,
a:visited {
  color: black
}

JavaScript

jQuery(function($) {
  var links = $('a.link');
  links.click(function() {
    // Remove the class from all other links
    links.removeClass('active');
    // Add the class to _just this link_
    $(this).addClass('active');
  });
});