odd and even – add class – jQuery

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
        $(document).ready(function() {
            $('ul.image-list li:even').addClass('even');
            $('ul.image-list li:odd').addClass('odd');
        });
 </script>

-- no conflict version
<script type="text/javascript">
jQuery.noConflict();
       jQuery(document).ready(function() {
            jQuery('ul.image-list li:even').addClass('even');
            jQuery('ul.image-list li:odd').addClass('odd');
        });
</script>

Leave a Reply