相关疑难解决方法(0)

如何在JQuery中打破/退出each()函数?

我有一些代码:

$(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)

javascript jquery

602
推荐指数
4
解决办法
66万
查看次数

在jQuery中针对每个循环嵌套内置$(this)

我试图弄清楚,当迭代一些列表项时,如何在嵌套的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)

html javascript jquery

42
推荐指数
3
解决办法
5万
查看次数

标签 统计

javascript ×2

jquery ×2

html ×1