Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

80
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda