<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script>
var area = [
//[""],
['朝阳' , '海淀' , '门头沟'],
['淮南' , '淮北' , '合肥']
];
function ld() {
var sel = document.getElementById('prov');
var opt = '';
if(sel.value == '-1') {
document.getElementById('city').innerHTML = opt;
return;
}
for(var i=0,len=area[sel.value].length; i<len; i++) {
opt = opt + '<option value="' + i + '">' + area[sel.value][i] + '</option>';
}
//alert(opt);
document.getElementById('city').innerHTML = opt;
}
</script>
</head>
<body>
<select name="" id="prov" onchange="ld();">
<option value="-1">
请选择
</option>
<option value="0">
北京
</option>
<option value="1">
安徽
</option>
</select>
<select name="" id="city">
</select>
</body>
</html>
达到联动菜单效果: