$("div").each(function(idx,a) { alert(a.id); return false; });. Returning false should stop the loop and print div1 only
$("div").each(function(idx,a) { alert(a.id); return true; });. Returning true shouldn't stop the loop and print div1 and div2