後我想刪除所有錶行的用戶點擊了複選框後,除了與自身的複選框的錶行,並在未選中該複選框再次顯示錶中的行後面。我的代碼僅用於刪除,但我需要在取消選中後再次顯示錶格。顯示/隱藏錶行點擊複選框
function Showhidefunc(btndel) {
if (typeof(btndel) == "object") {
$('table tr td:first-child :checkbox:not(:checked)').closest('tr').remove();
} else {
return false;
}
}
<thead>
<tr>
<th>Select</th>
<th>Month</th>
<th>Username</th>
<th>Deduction</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" onChange="Showhidefunc(this);"></td>
<td><?php echo $Name_row ['Month'];?></td>
<td><?php echo $Name_row ['Username'];?></td>
<td><?php echo $Name_row ['Total_Deduction'];?></td>
</tr>
</tbody>
謝謝你們:)
不要'一個.remove()'行 - 一旦你刪除它們,他們走了。使用'.hide()''然後.show()' –
你可以使用jQuery的[切換()](http://www.w3schools.com/jquery/eff_toggle.asp)。 –
也幫助我,謝謝。 –