我有一个名为性别的列表,只有两个值:男性和女性 .
我想要的是 table 上方的选择,当我选择男性时,只有性别列的行等于男性节目 .
如何在bootstrap-table中执行此操作?找不到任何类似的例子 .
你应该使用DataTables,它拥有一切:https://datatables.net/examples/styling/bootstrap.html
function myFunction() { var input, filter, table, tr, td, i; input = document.getElementById("myInput"); filter = input.value.toUpperCase(); table = document.getElementById("myTable"); tr = table.getElementsByTagName("tr"); for (i = 0; i < tr.length; i++) { td = tr[i].getElementsByTagName("td")[1]; if (td) { if (td.innerHTML.toUpperCase().indexOf(filter) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } }
在w3schools提供的代码here中,您唯一需要的是将 td = tr[i].getElementsByTagName("td")[1]; 中的数字更改为您需要的列数 .
td = tr[i].getElementsByTagName("td")[1];
2 回答
你应该使用DataTables,它拥有一切:https://datatables.net/examples/styling/bootstrap.html
在w3schools提供的代码here中,您唯一需要的是将
td = tr[i].getElementsByTagName("td")[1];
中的数字更改为您需要的列数 .