javascript - 我将如何切换此表,以便在使用 Javascript 单击它时仅隐藏行?
问题描述
我试图弄清楚单击表头时如何隐藏这些表中的行?我正在使用引导程序 5,所以 JQuery 不可用
<table class="table table-info table-bordered">
<thead id="tablea"> <!-- Table head -->
<tr>
<th scope="col">Column 2</th>
<th scope="col">Column 3</th>
</tr>
</thead>
<tbody class="table tables" id="body-a" data-action="hide">
{% for row in a %}
<tr> <!--Table rows -->
<td>{{row.column2}}</td>
<td>{{row.column3}}</td>
</tr>
{% endfor %}
</tbody>
</table>
<table class="table table-info table-bordered">
<thead>
<tr>
<th scope="col">Column 2</th>
</tr>
</thead>
<tbody class="table tables" id="body-b" data-action="hide">
{% for row in b %}
<tr>
<td>{{row.column2}}</td>
</tr>
{% endfor %}
</tbody>
</table>
解决方案
我不认为你可以在引导程序上完全做到这一点,但你可以使用 javaScript 中的切换类使用自定义 css 文件,如果它有助于引导表如何隐藏,请检查这个答案,当使用 javascript 切换可见时它不能正确显示
推荐阅读
- recursion - Coq 新手:如何在 Coq 中遍历二叉树
- javascript - Javascript .addEventListener 不起作用
- javascript - 根据属性过滤和映射数组对象
- javascript - Tawk.to href="javascript:void(Tawk_API.toggle())" 替代
- php - PHP数组中的天数的交集
- python - 使用 pandas UDF 重新索引日期会导致“java.lang.NullPointerException”
- python - 使用 Python 的 ReportLab 包从大文本文件生成 PDF 文档很慢
- java - 出站 DTO 验证:在 Spring Boot 中选择激活不同的验证模式/规则
- spring-cloud-dataflow - 如何为 SCDF 中的任务定义业务自定义属性?
- c# - 确定值是否不同