如何按bootstrap-table中的某列进行筛选?

How to filter by some column in bootstrap-table?

我有一个 table,其中有一列名为性别,只有两个值:男性和女性。

我要的是table上面的select,当我select男的时候,只有性别栏的行等于男的显示。

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]; 中的数字更改为您需要的列的数字。