【发布时间】:2018-04-10 10:56:04
【问题描述】:
我有一张非常简单的桌子。我正在尝试根据 HIST 列的值隐藏行。
基本上:
- 如果选择选择否,则仅显示 HIST = false 的行
- 如果选择说是,则显示所有行(无论是假还是真)
我被困在这里,但我不是很远。有什么帮助吗?
$('#historySelect').change(function() {
var option = $(this).val();
if (option === "No") {
} else {
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label>Show History
<select id="historySelect">
<option value="Yes">No</option>
<option value="No">Yes</option>
</select>
</label>
<table class="table dataTable no-footer" id="dataTable" cellspacing="0" width="100%" role="grid" aria-describedby="dataTable_info" style="width: 100%;">
<thead>
<tr role="row">
<th class="text-center text-primary sorting" tabindex="0" aria-controls="dataTable" rowspan="1" colspan="1" aria-label="Name: activate to sort column ascending" style="width: 66px;">Name</th>
<th class="text-center text-primary hidden sorting" tabindex="0" aria-controls="dataTable" rowspan="1" colspan="1" aria-label="Historic: activate to sort column ascending" style="width: 0px;">Historic</th>
</tr>
</thead>
<tbody>
<tr class="text-center hover-table odd" role="row">
<td>Name</td>
<td class="hist hidden">true</td>
</tr>
<tr class="text-center hover-table odd" role="row">
<td>Name</td>
<td class="hist hidden">false</td>
</tr>
</tbody>
</table>
【问题讨论】:
标签: javascript jquery