function getData() {
var data = new Array();
for (var i=0; i<list.length; i++) {
var city_text = list[i].firstChild.nodeValue;
var city = city_text.substring(0,2); //截取字符串,从0到2,但不包括2.
var num = list[i].lastChild.innerHTML;
data[i] = [city,num];
}
alert(data.length); //7
return data;
}
alert(data.length); //data is not defined
已经return data
了,外部的data
为何无法调用呢?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…