jQuery parentsUntil没有在其他条件下触发

时间:2013-08-30 14:23:22

标签: javascript jquery jstree

oK,这很奇怪......我有相同的代码,在if语句中效果很好......但是当它到达else语句时它不会触发parentsUntil ????

 if(sArray.length > 400){

 $.each(sArray,  function(key, item){

                    $("!#"+item).parentsUntil(".#jstree").filter(".#jstree-closed").each(function () { 
                            $aTree.jstree("close_all", this); 
                            }); 
                  });

else{

 $.each(sArray,  function(key, item){

                    $("!#"+item).parentsUntil(".#jstree").filter(".#jstree-closed").each(function () { 
//IT IS NOT MAKING IT HERE
                            $aTree.jstree("close_all", this); 
                            }); 
                  });


}

1 个答案:

答案 0 :(得分:1)

你错过了2}以及控制台给你的东西:

if(sArray.length > 400){

     $.each(sArray,  function(key, item){
        $("#"+item).parentsUntil(".jstree").filter(".jstree-closed").each(function () { 
            $aTree.jstree("check_node", this); 
        }); 
    });

}// Was missing
else{

$.each(sArray,  function(key, item){
    console.log($("#"+item).parentsUntil(".jstree").filter(".jstree-closed"));
    $("#"+item).parentsUntil(".jstree").filter(".jstree-closed").each(function () { 
            //IT IS NOT MAKING IT HERE
            console.log("pass");
            $aTree.jstree("check_node", this); 
        }); 
    });
}