> The problem is that jQuery assigns a class of 'roweven' to odd
> numbered <tr> elements and a class of 'rowodd' to even numbered <tr>
> elements across all browsers. I've tested this on jQuery 1.3.2 and
> jQuery 1.3.1.

The :even and :odd filters are zero-based, so if you select (in your
example) 10 rows, the 1. row has index 0 and will be matched by
the :even filter, the 2. row has index 1 and will be matched by :odd,
and so on....




> <script type="text/javascript">
> $(document).ready(function() {
>         var j = 0;
>         var rows = $('#foobar tbody tr:visible');
>         for (i = 0; i < rows.length; i++){
>                 j++;
>                 if (j % 2 == 0) {
>                         rows[i].className = 'roweven';
>                 }
>                 else {
>                         rows[i].className = 'rowodd';
>                 }
>         }});
>
> </script>

I changed these 2 lines...
rows[i].className = 'roweven';
rows[i].className = 'rowodd';

to this:
rows.eq(i).addClass('roweven');
rows.eq(i).addClass('rowodd');

and now it works in IE8

Reply via email to