0
我想要一個表分頁,並在表頭中同時搜索框。因此,使用此代碼jsfiddle pagination過濾表與分頁
這裏是我的過濾代碼:
function searchCabinet() {
var input, filter, table, tr, td, i;
input = document.getElementById("searchCabinet");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
搜索框不能正常工作 – Kyrie
你的意思不工作是什麼......這表明該行如果輸入的是什麼?在至少1列中找到 – Vanojx1