var i = 0;
$("a").each(function(){
if( ++i > 10 )
return; // break out of each() loop after 10th link
$(this).attr( "title", "Link # " + i );
});
Tip: you can also use "return false", "return true", or return some other expression or value, depending on how your code is handled, if you pick up a result from that function, etc.
$(".linkPanels").each(function(){
for( var i=0; i<10; ++i ) { // each contains up to 10 links
if( i > $(this).children().length )
break; // Stop with early exit after last child
$(this).children().eq(i).html("Link # " + i );
}
// Resume with post-loop code execution here...
});