Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

76
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!