JSFiddle - React, Tailwind, and code Playground

HTML

<nav>
 <ul>
  <li class="navServe" data-target=".services">services</li>
  <li class="navContact" data-target=".contact">contact</li>
 </ul>
</nav>

<section class="services s-h">
 <h1>Contents of services section</h1>
</section>

<section class="contact s-h">
 <h1>Contents of contact section</h1>
</section>

JavaScript

$("nav ul li").click(function(){
   $(".s-h").hide();
   var elem = $(this).attr("data-target");
   $(elem).show();
});