I need to implement some full text searching on table. This fiddle is a snippet i have found, but it only searches through the first column of a table, ie. ID column. I need to improve this to seach through whole table. Code:
$(document).ready(function(){
$("#search").on("keyup", function () {
var value = $(this).val();
$("table tr").each(function (index) {
if (index !== 0) {
$row = $(this);
var id = $row.find("td").text();
if (id.indexOf(value) !== 0) {
$row.hide();
}
else {
$row.show();
}
}
});
});
});
var id = $row.find("td").text();
For your use u just have to change the condition ab bit:
FROM:
if (id.indexOf(value) !== 0) {
TO:
if (id.indexOf(value) === -1) {
COMPLETE:
$(document).ready(function(){
$("#search").on("keyup", function () {
var value = $(this).val();
$("table tr").each(function (index) {
if (index !== 0) {
$row = $(this);
var id = $row.find("td").text();
if (id.indexOf(value) === -1) {
$row.hide();
}
else {
$row.show();
}
}
});
});
});