JSFiddle - React, Tailwind, and code Playground
by tridd3r
HTML
<div class="input-group input-group-sm mb-2">
<input class="form-control" id="search" type="text" placeholder="Search.." >
<a href="{% url 'view_toners' %}" class="btn btn-dark btn-sm"><i class="fas fa-sync-alt"></i></a>
</div>
<table id="myTable" class="table table-striped" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011-04-25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011-07-25</td>
<td>$170,750</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009-01-12</td>
<td>$86,000</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012-03-29</td>
<td>$433,060</td>
</tr>
<tr>
<td>Airi Satou</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>33</td>
<td>2008-11-28</td>
<td>$162,700</td>
</tr>
<tr>
<td>Brielle Williamson</td>
<td>Integration Specialist</td>
<td>New York</td>
...
JavaScript
$(document).ready(function(){
$("#search").on("keyup",function(){//missing the # for the search ID
let value = $(this).val() //You weren't defining value at all??
$("table tr").each(function(e){
if(e!==0){
$go=$(this)
$go.find('td').each(function(){
var id=$(this).text().toLowerCase();//moved the toLowerCase here and text needs parenthesis
if(id.indexOf(value.toLowerCase())===-1 ){//simplify the logic -1 == not found
$go.hide();
}else{
$go.show();
return false;
}
});
}
var isNone=$("#myTable tr:not('.chk-th'):visible");
if(isNone.length==0){
$("#no-data").text("No product found").show();
}
else{
$("#no-data").text("No product found").hide();
}
});
});
});