【发布时间】:2019-12-14 01:30:21
【问题描述】:
我试图隐藏我的一列的表值,因为它有超过 10 个值,并且仅在您单击加号时显示它。否则,当您单击减号时,它会隐藏列值
我的尝试如下。它有效,但不是我想要的方式。当您单击加号时,它只显示第一个值而不是其余值。 我对 JS 了解不多,谁能给我更多关于如何处理这个问题的线索?
这是我的代码
HTML
<table>
<thead>
<tr>
<th>Forms</th>
</tr>
</thead>
<tbody>
<tr>
<td id="details-control" class="details-open">
<span id='content' class="d-none"><?= $row->getElement()?><br> </span>
</td>
</tr>
</tbody>
CSS
td.details-open {
background: url("../img/details_open.png") no-repeat center center;
cursor: pointer;
}
td.details-close {
background: url("../img/details_close.png") no-repeat center center;
}
我的脚本
$(document).ready(function(){
$('#details-control').on('click', function (e) {
$("#content").removeClass("d-none")
$("#details-control").removeClass("details-open")
$("#details-control").addClass("details-close")
});
});
【问题讨论】:
-
把你的 html 放在这里,因为 php 代码在这里不起作用。
-
html 已发布。这是我要操作的表格数据
-
打印表格和打印的html粘贴到这里。
标签: javascript php jquery datatable datatables