jQuery, WP: Add class to every 3rd Xth element
var i = 1; $('#row .fourcol').each(function() { if(i++ % 4 == 0) $(this).addClass('last'); });