I want to do a live search through the table rows, using jQuery, the \"live\" word is the key, because I want to type the keywords in the text input, on the same site and I\
Hey for everyone still looking in 2020. I took some answers from here and made my own searchTable function.
function searchTable() {
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("showTable");
tr = table.getElementsByTagName("tr");
th = table.getElementsByTagName("th");
var tdarray = [];
var txtValue = [];
for (i = 0; i < tr.length; i++) {
for ( j = 0; j < th.length; j++) {
tdarray[j] = tr[i].getElementsByTagName("td")[j];
}
if (tdarray) {
for (var x = 0; x < tdarray.length; x++) {
if (typeof tdarray[x] !== "undefined") {
txtValue[x] = tdarray[x].textContent || tdarray[x].innerText;
if (txtValue[x].toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
}
}