Add rel="lightbox" to links with .jpg and .gif in them
===

I'm trying to make a simple script that adds rel="lightbox" to links with .jpg or .gif in the href. Can someone help me? I can't see the mistake. Thank you.

    <script type="text/javascript">

           $('a[href*=".jpg"]').each(function() {
              $('a[href*=".gif"]').each(function() {
                  $(this).attr('rel','lightbox'); 
              });
           });

    </script>