To exit .each(), just usereturn false;
See jQuery .each()docs for more information.
, :
$("button").click(function() {
$("div").each(function(index, domEle) {
$(domEle).css("backgroundColor", "yellow");
if ($(this).is("#stop")) {
$("span").text("Stopped at div index #" + index);
return false;
}
});
});