使用类隐藏表格中的一行

问题描述:

我的表格中有两行的倍数如下。我想在页面加载时在表格的任何位置隐藏第二行模式。使用类隐藏表格中的一行

我试图用类“a-IRR-header”来隐藏,但它隐藏了两个行,因为它是两行的公共类。

<tr> 
 
    <th colspan="4" class="a-IRR-header a-IRR-header--group" id="B139078761545827132_1">Basis</th> 
 
</tr> 
 
<tr> 
 
    <th class="a-IRR-header" id="C139079212590827137"><a data-column="139079212590827137" href="#">Sl</a></th> 
 
    <th class="a-IRR-header" id="C139078981375827134"><a data-column="139078981375827134" href="#">Question</a></th> 
 
    <th class="a-IRR-header" id="C139079056068827135"><a data-column="139079056068827135" href="#">Answer</a></th> 
 
</tr>

+0

'$( 'A-IRR报头')。方程(1).hide()' – guradio

+1

重新格式化HTML后,它会显示您的*行*没有任何类。我建议**在你需要的地方添加额外的班级**。 –

+0

@guradio如果我有多行重复提到的两行,那么该怎么办? –

你可以这样做:

$(document).ready(function(){ 
    $('tr:eq(1)').hide(); 
}); 

有3个,而不是与类A-IRR头所有TR - 组的Cuz有与TR标签3日与其他类,我不想打扰:

$.each('tr').function({ 
    if($(this).find('th').not('.a-IRR-header').length == 3) 
    { 
     $(this).parents('tr:first').hide(); 
    } 
}); 
+0

如果我提到了2行的倍数,说50行。我想要选择性地隐藏上面问题中第二行类型的行。另外,假设class =“a-IRR-headerLink”不存在。请回答 –

+0

所以你想要隐藏所有TR中将有三个TH? –

+0

是himanshu。所有tr与第3,而不是类与a-IRR-header-group cuz有tr标签与第3与其他类,我不想打扰。 –

可以achiev E本采用CCS nth-child()喜欢:

table tr:nth-child(2) { 
    background: #ccc; 
} 

例:

table tr:nth-child(2) { 
 
    background: #ccc; 
 
}
<table width="100%" border="1"> 
 
    <tr> 
 
    <td>&nbsp;</td> 
 
    <td>$</td> 
 
    <td>&nbsp;</td> 
 
    </tr> 
 
    <tr> 
 
    <td>&nbsp;</td> 
 
    <td>$</td> 
 
    <td>&nbsp;</td> 
 
    </tr> 
 
    <!-- 
 
    <tr> 
 
    <td>&nbsp;</td> 
 
    <td>$</td> 
 
    <td>&nbsp;</td> 
 
    </tr> 
 
    <tr> 
 
    <td>&nbsp;</td> 
 
    <td>$</td> 
 
    <td>&nbsp;</td> 
 
    </tr> 
 
    <tr> 
 
    <td>&nbsp;</td> 
 
    <td>$</td> 
 
    <td>&nbsp;</td> 
 
    </tr> 
 
    --> 
 
</table>

首先,我认为你应该检查你的班,有太多的大写字母的语法(这是个人意见,但它会帮助你)。

我真的不明白你想要做什么,但你可以使用CSS选择器:如果你真的需要隐藏的负载,你可以使用的东西

table tr:nth-child(2) { 
    display: none; 
} 

就像:

$(document).ready(function() { 
    $("table tr:nth-child(2)").css('display', 'none'); 
}) 
+0

这些类是由Oracle apex内置的。我也想知道如果我有多行是重复提到的2行。 –

+0

对,我不知道它:)!我编辑我的帖子它应该工作。 –

$(document).ready(function() { 
 
    $('.a-IRR-header').eq(1).hide() 
 
});
table tr:nth-child(2) { 
 
    background: green; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<table width="100%" border="1"> 
 
    <tr> 
 
     <th colspan="4" class="a-IRR-header a-IRR-header--group" id="B139078761545827132_1">Basis</th> 
 
    </tr> 
 
    <tr> 
 
     <th class="a-IRR-header" id="C139079212590827137"><a class="a-IRR-headerLink" data-column="139079212590827137" href="#">Sl</a></th> 
 
     <th class="a-IRR-header" id="C139078981375827134"><a class="a-IRR-headerLink" data-column="139078981375827134" href="#">Question</a></th> 
 
     <th class="a-IRR-header" id="C139079056068827135"><a class="a-IRR-headerLink" data-column="139079056068827135" href="#">Answer</a></th> 
 
    </tr> 
 
</table>