how to break out from outer each loop

后端 未结 2 452
我在风中等你
我在风中等你 2021-01-04 14:30

I have the following scenario:

$.each(array, function() {
    ...
    $.each(array1, function() {
        if condition () { }
    });
});

H

2条回答
  •  孤城傲影
    2021-01-04 14:58

    Set a value to test in the outer loop to exit

    $.each(array, function() {
        var exit = false;
        $.each(array1, function() {
            if ( condition ) { 
               exit = true;
               return false;
            }
        }
        if (exit){
            return false;
        }
    }
    

提交回复
热议问题