Treat each group of li's independantly?

Treat each group of li's independantly?

 Hi, friends,

in this code I may have serveral ul's

How can I apply this so that it treats each group of li's independantly? ie the numbering starts fresh for each ul group?






  1. <script type="text/javascript">
  2. (function($){
  3. $(document).ready(function() {
  4. $("ul > li").each(function(i) {
  5. if (i % 2 == 1)
  6. {
  7. $(this).addClass("odd");
  8. }
  9. else
  10. {
  11. $(this).addClass("even");
  12. }
  13. });
  14. });
  15. })(jQuery);
  16. </script>