Search HTML Table
Search HTML Table
HTML
<input type="text" id="search" placeholder="Hız Seçeneği">
<input type="text" id="search2" placeholder="Kota / AKK">
<table id="table">
<tr>
<td>24 Mbps</td>
<td>50 GB AKK</td>
</tr>
<tr>
<td>25 Mbps</td>
<td>100 GB AKK</td>
</tr>
<tr>
<td>50 Mbps</td>
<td>250 GB KOTA</td>
</tr>
<tr>
<td>24 Mbps</td>
<td>150 GB AKK</td>
</tr>
</table>
CSS
body {padding: 20px;}
input {margin-bottom: 5px; padding: 2px 3px; width: 209px;}
td {padding: 4px; border: 1px #CCC solid; width: 100px;}
JavaScript
var $rows = $('#table tr');
$('#search').keyup(function() {
var val = '^(?=.*\\b' + $.trim($(this).val()).split(/\s+/).join('\\b)(?=.*\\b') + ').*$',
reg = RegExp(val, 'i'),
text;
$rows.show().filter(function() {
text = $(this).text().replace(/\s+/g, ' ');
return !reg.test(text);
}).hide();
});
var $rows = $('#table tr');
$('#search2').keyup(function() {
var val = '^(?=.*\\b' + $.trim($(this).val()).split(/\s+/).join('\\b)(?=.*\\b') + ').*$',
reg = RegExp(val, 'i'),
text;
$rows.show().filter(function() {
text = $(this).text().replace(/\s+/g, ' ');
return !reg.test(text);
}).hide();
});