Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

77
Visualizações
jQuery search a relevant th column only
<table>
 <thead>
   <th>Code</th>
   <th>Name</th>
   <th>barcode</th>
 </thead>
 <tbody>
   <tr>
     <td>1</td>
     <td>Milk</td>
     <td>504</td>
   </tr>
   <tr>
     <td>2</td>
     <td>Cheese</td>
     <td>302</td>
   </tr>
   <tr>
     <td>3</td>
     <td>Butter</td>
     <td>654</td>
   </tr>
 </tbody>

Above is the table I created.Using jQuery I want to search for the data using a particular th .For example I want to search this able by using the code only So If I input 1 the first record will come, And If I want to search the table using the Name only when I start typing the name the particular record should come.Just I should want to apply (search by the code,search by the name,search by the barcode) those options.I have tried this but this return all the records of every field, I want to search by a particular field only this is the way I tried,

$(document).on('keyup', '#searchProduct', function(){
       var searchKey = $(this).val().toLowerCase();

       $('#productTable tbody tr').each(function(){
           var str = $(this).text().toLowerCase();

           if(str.indexOf(searchKey) == -1){
               $(this).hide();
           } else {
               $(this).show();
           }
       });
 });
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda