这个问题在这里已有答案:
我有一些代码:
$(xml).find("strengths").each(function() {
//Code
//How can i escape from this block based on a condition.
});
如何根据条件从“每个”代码块中逃脱?
更新:
如果我们有这样的事情怎么办:
$(xml).find("strengths").each(function() {
$(this).each(function() {
//I want to break out from both each loops at the same time.
});
});
是否有可能从内部“每个”功能中突破“每个”功能?
# 19.03.2013
If you want to continue instead of break out
return true;
4 回答
根据documentation你可以简单地
return false;
来打破:从匿名函数返回false:
从each method的文档:
你可以用
return false;
请参阅similar question 3天前询问 .