我有以下js脚本
$('#module-listing > tbody > tr').each(function(){
$(this).toggle('show');
});
如何更改显示的每个td
的第一个tr
?
答案 0 :(得分:1)
使用:first-of-type
$(#module-listing > tbody > tr >
td:第一类型 )
$('#module-listing > tbody > tr > td:first-of-type').each(function(){
$(this).toggle('show');
});
td {visibility: collapsed;}
.show {visibility: visible;}
<table id='module-listing'>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
</table>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>