I'll start fresh. I have a table pulled from a remote server. The table has white odd rows and grey even rows. I've hidden some rows:
$("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 Now my table rows no longer alternate but is instead white, grey, grey, grey, white. How do I make them alternate again? Creating a class like: $("tr").filter(":even").addClass("even"); + css tr.even td{background-color: blue;} makes it white, blue, blue, blue, white so it still doesn't alternate.
I can do this $('tr:nth-child(4)').each(function(i){ $(this).find('td').css('background-color', 'white');}); and it works white, grey, WHITE, grey, white. But there's a catch! Row 4 has red cells that I want to remain red. The code above overrides the red cells to white.
The style from the server is:
<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> I want this red alert color to remain red while the rows alternate to white and grey.
!important?!importantis a very bad idea