日期:2014-05-16  浏览次数:20339 次

数组arr1(二维),arr2(一维),arr3(一维),将arr1第二列中与arr2相同的数组输出到arr3
var arr1 = new Array();
arr1[0] = new Array (1,1,"├标准");
arr1[1] = new Array (1,15,"│ ├法规");
arr1[2] = new Array (1,19,"│ ├文件");
arr1[3] = new Array (1,2,"├队伍");
arr1[4] = new Array (1,3,"├动态");
arr1[5] = new Array (1,47,"│ ├领导");
arr1[6] = new Array (2,48,"│ ├工作");
arr1[7] = new Array (2,49,"│ ├推普");


var cTmp = "";  
var j = 1;
var arr2 = [1,15,19];
var arr3= [];
for(var s in arr1){
for(var x in arr2){
if(arr1[s][1]==arr2[x]){
arr3.push(arr1[s][0],arr1[s][1],arr1[s][2]);
}
}
}

alert(arr3);

alert的arr3没有任何输出,不知是哪里出了问题。


------解决方案--------------------
可能就是你调用有问题。用firebug看看控制台报什么错。