<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>二位数组遍历打印城市</title>
</head>
<body>
<script>
["宜昌市","荆州市","黄石市"],
["长沙市","郴洲市","常德市"]];
var input=prompt("输入省份:如上海市,武汉市,湖南省");
for(var i=0;i<provs.length;i++){
if(input==provs[i]){
document.write(cities[i]);
break;
}else if(i==provs.length-1){
document.write("您输入的城市信息没有涉及!");
break;
}
}
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>二位数组遍历打印城市</title>
</head>
<body>
<script>
var provs=["上海市","武汉市","湖南省"];
["宜昌市","荆州市","黄石市"],
["长沙市","郴洲市","常德市"]];
var input=prompt("输入省份:如上海市,武汉市,湖南省");
for(var i=0;i<provs.length;i++){
if(input==provs[i]){
document.write(cities[i]);
break;
}else if(i==provs.length-1){
document.write("您输入的城市信息没有涉及!");
break;
}
}
</script>
</body>
</html>