$('div.listing-item:odd').addClass('odd');
$('div.listing-item:even').addClass('even');

I think this should work

On Jul 14, 7:01 am, sutra <[EMAIL PROTECTED]> wrote:
> I have a product listing like this :
> <div class="listing">
> .....</div>
>
> I want to add different background color for the odd and even  listing
> like so:
>
> <div class="listing odd">
> .....</div>
>
> <div class="listing even">
> .....</div>
>
> <div class="listing odd">
> .....</div>
>
> I know how to use the simple addClass function in jQuery, but I am
> unable to figure how to add the 'even' class. This is my code, can you
> please tell me what I did wrong?
>
>  <script>
>         var $j = jQuery.noConflict();
>         $j(document).ready(function() {
>          $j("div.listing-item").addClass("odd") {
>          $j(this).parent("div.listing-
> item").next().siblings("odd").addClass("even"); ;
>
>     });
>
>  </script>
>
> Many thanks!

Reply via email to