我要隐藏所有<tr>
单击的表。
<table>
<tr>
<td>ABC</td>
<td>DEF</td>
<td><i class="delete">delete </i></td>
</tr>
<tr>
<td>ABC</td>
<td>DEF</td>
<td><i class="delete">delete </i></td>
</tr>
</table>
单击删除按钮后,将隐藏除当前以外的所有行。
jQuery代码:-
$(document).ready(function () {
$('table tbody tr').siblings().not($(this)).hide();
});
请给我建议。
用途siblings
如下:
参见代码中的内联注释:
// Bind click event on `tr` inside `table`
$('table').on('click', 'tr', function () {
// Show current `tr` and hide others
$(this).siblings().hide();
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句