2017-09-15 15 views
-1

私は以下のように私のテーブルに2行の倍数を持っています。ページの読み込み時にテーブルのどこにでも2行目のパターンを隠したいと思っていました。クラスを使用してテーブル内の行を非表示

クラス「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

'$( '-IRR-ヘッダ')。EQ(1).hide()' – guradio

+1

HTMLを再フォーマットした後、*行*にクラスがないことが示されます。私は**あなたがそれらを必要とする場所で**クラスを追加することをお勧めします。 –

+0

@guradioもし2行の繰り返しである複数の行がある場合 –

答えて

0

あなたはこのように行うことができます。

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

3番目ではなく、クラスで-IRR-ヘッダを持つすべてのTR - グループとTRタグがあるのcuz私は邪魔したくない他のクラスと3番目:

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

もし私が言及された2行の倍数を持っているなら、何か50行を言うでしょう。そして、私は上記の質問で2行目のタイプの行を選択的に隠したいと思っています。また、class = "a-IRR-headerLink"が存在しないと仮定します。 –

+0

と答えてください。THを3つ持つTRをすべて非表示にしたいのですか? –

+0

はい甘粛。すべてのtrは、3番目のクラスではなく、IRRヘッダーのグループのcuzと一緒に3番目のtrのタグは、他のクラスと混乱したくないです。 –

0

あなたは達成することができます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>

0

まず(これを個人的な意見ですが、それはあなたを助けるでしょう)。

私は本当にあなたが何をしようとして理解していないが、あなたはCSSセレクタを使用することができます:あなたは本当にあなたが何かを使用することができ、負荷にそれを非表示にする必要がある場合は

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

は次のようだ:

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

これらのクラスはOracle apex inbuiltによって追加されます。私はまた、私は2行の繰り返しである複数の行を持っている場合は知りたかった。 –

+0

私はそれについて知らなかった:)私はそれがうまくいくはずの投稿を編集しました。 –

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>

関連する問題