<html>
<head>
<script>
var arr = [
['朝阳','海淀','房山'],
['济南','青岛','烟台']
]
function ld()
{
var sel = document.getElementById('sheng');
var opt = "";
if(sel.value=='-1'){document.getElementById('shi').innerHTML = opt;}
for(var i = 0;i<arr[sel.value].length;i++)
{
opt = opt+'<option value="'+i+'">'+arr[sel.value][i]+'</option>';
}
document.getElementById('shi').innerHTML = opt;
}
</script>
</head>
<body>
<select id='sheng' οnchange='ld()'>
<option value='-1'>请选择</option>
<option value='0'>北京</option>
<option value='1'>山东</option>
</select>
<select id='shi'></select>
</body>
</html>
js联动菜单Demo
最新推荐文章于 2021-10-11 15:17:50 发布