实现表格的折叠
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="../plugins/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<link href="../plugins/layui/2.5.6/css/layui.css" rel="stylesheet">
<script src="../plugins/jquery/jquery-3.6.0.min.js"></script>
<script src="../plugins/layui/2.5.6/layui.all.js"></script>
<script src="../plugins/ui-frame/layer/2.2/layer.js"></script>
<script src="../plugins/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="../plugins/bootstrap-table/js/bootstrap-table.min.js"></script>
<script src="../plugins/bootstrap-table/js/bootstrap-table-zh-CN.min.js"></script>
</head>
<body>
<script>
$(function () {
$(".detail").click(function () {
var that = this;
$(that).parent().next().toggle();
})
})
</script>
<div class="htmleaf-container">
<table border="1px" id="dataTable">
<thead>
<tr>
<th>折叠/展开</th>
<th>姓名</th>
<th>性别</th>
<th>学校</th>
</tr>
</thead>
<tbody>
<tr>
<th class="detail">折叠</th>
<th>啊啊啊</th>
<th>啊啊啊</th>
<th>啊啊啊</th>
</tr>
<tr class="view">
<td colspan="4">
<p>id:1111</p>
<p>name:1111</p>
<p>sex:1111</p>
<p>loc:1111</p>
</td>
</tr>
<tr>
<th class="detail">折叠</th>
<th>啊啊啊</th>
<th>啊啊啊</th>
<th>啊啊啊</th>
</tr>
<tr class="view">
<td colspan="4">
<p>啊啊啊</p>
<p>啊啊啊</p>
<p>啊啊啊</p>
<p>啊啊啊</p>
<p>啊啊啊</p>
</td>
</tr>
<tr>
<th class="detail">折叠</th>
<th>啊啊啊</th>
<th>啊啊啊</th>
<th>啊啊啊</th>
</tr>
<tr class="view">
<td colspan="4">
<p>ssssss</p>
<p>啊啊啊</p>
<p>啊啊啊</p>
<p>啊啊啊</p>
<p>啊啊啊</p>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
主要通过jquery设置显示和隐藏