Need help with adding a class to a specific item in a loop

Discussion in 'Programming' started by rob7676, Nov 11, 2010.

  1. #1
    In my design, I have 3 col to display the latest from a blog. I ran the wordpress loop to return 3 results and now I need to add a class to the last (or 3rd) div in the loops return. This is what I have, any help would be much appreciated.
    
    <script type="text/javascript">
    	$(".blog:last").addClass('last');			
    </script>
    <?php query_posts('post_per_page=3'); ?>
    <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
    
    <div class="three-even blog">
         content goes here......
    </div><!--END three-even last-->
        
    <?php endwhile; ?>
        
    <?php endif; ?>
    
    Code (markup):

     
    rob7676, Nov 11, 2010 IP