把一个数组遍历倒序放到另一个数组中,数组取值是c:out value
1 var year = "<c:out value="${year}" />"; 2 3 var years = []; 4 5 var yearDataArray = []; 6 //遍历year,放进yearDataArray中 7 $("#year option[value!='']").each(function(){ 8 yearDataArray.push($(this).text()); 9 }); 10 //yearDataArray排序 11 yearDataArray = yearDataArray.sort(function(a,b){ 12 return a-b; 13 }) 14 //对yearDataArray 的每一个值加上后缀,放进years中 15 $.each(yearDataArray, function(i, d){ 16 years.push(yearDataArray[i]+"-01-01"); 17 });