我试图在单击th时显示表格行,但我不知道如何做到这一点。这是我目前所拥有的:
<th colspan="3" class="subth">Empresa São João</th>
<tr class="hidethis">
<td>1</td>
<td>Linha Tangerina</td>
<td>R$ 20,05</td>
</tr>JQuery/JavaScript是这样的:
$('.hidethis').hide();
$('.subth').click(function(){
$(this).next().toggle();
});我的意思是,如果这部分代码还不够,我可以在
*编辑:*隐藏起作用了,不起作用的是切换!谢谢
如果我使用这个:$('tbody').click(function(){ $(this).find('tr').toggle(); });
它“工作”的事情是:我有两个th与tr的,所以它们同时显示。
*编辑2.0:*
伙计们,我有点明白了!我的意思是,它并不完美,因为它总是显示一组<tr>,但它很好,我猜这是我想出的代码(它可能搞砸了,哈哈)
$('.hidethis2').hide();
$('tbody').click(function(){
$('tr.hidethis').toggle();
$('tr.hidethis2').toggle();
});谢谢!
发布于 2016-09-21 00:52:39
试一试
$(document).ready(function(){
$('th').click(function(){
$('.next-tr').fadeToggle();
});
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table style="width:100%;">
<tr height="25">
<th width="50%">1St</th>
<th width="50%">2Nd</th>
</tr>
<tr class="next-tr">
<td style="text-align:center;">1</td>
<td style="text-align:center;">2</td>
</tr>
</table>
https://stackoverflow.com/questions/39599532
复制相似问题