我有一些代码:
$(xml).find("strengths").each(function() {
//Code
//How can i escape from this block based on a condition.
});
Run Code Online (Sandbox Code Playgroud)
如何根据条件从"每个"代码块中逃脱?
如果我们有这样的事情怎么办:
$(xml).find("strengths").each(function() {
$(this).each(function() {
//I want to break out from both each loops at the same time.
});
});
Run Code Online (Sandbox Code Playgroud)
是否有可能从内部"每个"功能中突破"每个"功能?
#19.03.2013
如果你想继续而不是爆发
return true;
Run Code Online (Sandbox Code Playgroud) 我试图弄清楚,当迭代一些列表项时,如何在嵌套的foreach循环中定位每个"$(this)"等价物.这是我的问题的一个例子:
$('li').each(function(){
// I believe $(this) would target each li item...
$(this).children("li").each(function(){
// ... but how can I target each of these li items? Doesn't $(this) target the original loop?
});
});
Run Code Online (Sandbox Code Playgroud)