jQuery中each循环的跳出和结束

jQuery中each类似于javascript的for循环 
但不同于for循环的是在each里面不能使用break结束循环,也不能使用continue来结束本次循环,想要实现类似的功能就只能用return,
break           用return false
continue      用return ture

 var tab1 = [0,1,2,3,4,5,6];
    var tab_2 = [];
    $(tab1).each(function(i,el){
        if(el < 5 && el >2) return false;
        tab_2.push(el);
    });
    console.log(tab_2);
//false =>[0,1,2]
//true => [0, 1, 2, 5, 6]
原文地址:https://www.cnblogs.com/gxp69/p/7365529.html