私は新たに始めます。リモート サーバーから取得したテーブルがあります。テーブルには、白い奇数行と灰色の偶数行があります。いくつかの行を非表示にしました:
$("td").filter(function(){ return $(this).text()=='R1';}).text('Row1'); //white
$("td").filter(function(){ return $(this).text()=='R2';}).text('Row2'); //grey
$('tr:nth-child(3)').hide(); //white
$("td").filter(function(){ return $(this).text()=='R4';}).text('Row4'); //grey
$('tr:nth-child(5)').hide(); //white
$("td").filter(function(){ return $(this).text()=='R6';}).text('Row6'); //grey
$("td").filter(function(){ return $(this).text()=='R7';}).text('Row7'); //white
現在、テーブルの行は交互ではなく、白、灰色、灰色、灰色、白になっています。それらを再び交互にするにはどうすればよいですか?$("tr").filter(":even").addClass("even");
+ cssのようなクラスを作成するtr.even td{background-color: blue;}
と、白、青、青、青、白になるため、まだ交互にはなりません。
私はこれを行うことができ$('tr:nth-child(4)').each(function(i){ $(this).find('td').css('background-color', 'white');});
、白、グレー、白、グレー、白で機能します。しかし、落とし穴があります。行 4 には、赤のままにしたい赤血球があります。上記のコードは、赤のセルを白にオーバーライドします。
サーバーからのスタイルは次のとおりです。
<script src="remoteserver/sorttable.js"></script>
<style type = "text/css">';
td.datacellone{
background-color: #C0C0C0;
}
th.datacellheader{
background-color: #6A5ACD;
}
td.alert{
background-color: #FF0000;
}
td.orange{
background-color: #FFA500;
}
td.green{
background-color: #008000;
}
</style>
行が白と灰色に交互になる間、この赤い警告色を赤のままにしたい.