breaking the .each loop

breaking the .each loop

I have this code for loop breaking in table rows
rows = $('#tableid .trclick').nextAll().each(
function() {
if($(this).hasClass("sub1"))
{
//do something
}
else
{
break;
}

This code does not break and give error. Does anybody know why or anyone has alternate solution?