'Trying to use an array of indexes for a custom live search via js
This is my code... I would basically like to make this line (td = tr[i].querySelectorAll(".table-data")[0];) I want this part...[0] to be something like this [0,5]
function myFunction() {
var input, filter, table, tr, td, i, txtValue;
input = document.querySelector("#myInput");
filter = input.value.toUpperCase();
table = document.querySelector("#myTable");
tr = table.querySelectorAll(".row");
for (i = 0; i < tr.length; i++) {
td = tr[i].querySelectorAll(".table-data")[0];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
