JSFiddle - React, Tailwind, and code Playground

by tuga

HTML

<input type="text" id="searchcity">
<div id="citysname">
    <a href="#" id="place" class="kathmandu">Kathmandu</a>
    <a href="#" id="place" class="bhaktapur">bhaktapur</a>
    <a href="#" id="place" class="Narayangarh">Narayangarh</a>
    <a href="#" id="place" class="lalitpur">lalitpur</a>
    <a href="#" id="place" class="something">something</a>
    <a href="#" id="place" class="hello">hello</a>
</div>

JavaScript

$(document).ready(function(){ 

$(document).on("keyup", "#searchcity", function(){
     var city = $(this).val();
     
     $( "#citysname a" ).each(function() {
         var classCity = $(this).attr("class");
         if(city === classCity){
            console.log("match");  
              $(this).show();
         }else{
             $(this).hide();
         }
          
         
      //$(this).not('[class^='+ city +']').hide();
      //$(this+' [class^='+ city +']').show();
    });
   });
});