Search code examples
jquerycssinternet-explorer-8zebra-striping

Zebra stripping not working in IE8


I wrote the following jquery to apply zebra stripping to a certain row in a table. This works fine in Chrome and Firefox but doesnt work in IE8. W

<script>
$(document).ready(function()
{
$("tr.alt:even").css("background-color", "#f0f8ff");
$("tr.alt:odd").css("background-color", "#fcfceb");
});
</script>

Here is the HTML

<tr class="alt">
    <td class="status"></td>
    <td class>Received</td>
</tr>
<tr class="alt">
    <td class="status"></td>
    <td class>Received</td>
</tr>
<tr class="alt">
    <td class="status"></td>
    <td class>Received</td>
</tr>
<tr class="alt">
    <td class="status></td>
    <td class>Received</td>
</tr>
<tr class="alt">
    <td class="status></td>
    <td class>Received</td>
</tr>

Solution

  • <style type="text/css">
      tr.odd 
    {
        background:fcfceb;
    }   
      tr.even 
    {
        background:f0f8ff;
    }
    tr.zero 
    {
        background-color:#FFE4E1;
    }
    </style>
    
    <script>
      jQuery(function($) {
        $("tr.alternateColor:odd").addClass("odd");
        $("tr.alternateColor:even").addClass("even");
    </script>
    

    Finally got it to run. I was having issues with my CSS in IE