其他分享
首页 > 其他分享> > Jquery省市级连

Jquery省市级连

作者:互联网

<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript">
function changes (v) {
//定义城市的数组
var citys=[
["郑州","洛阳","新乡","驻马店"],
["济南","济宁","青岛","烟台"],
["太原","大同","运城","长治"]
];
//清空下拉列表
document.getElementById("shi").innerHTML="";
//根据被选中省的value值循环读取城市
for (var i = 0; i < citys[v].length; i++) {
document.getElementById("shi").innerHTML
+="<option>"+citys[v][i]+"</option>";
}
}
</script>

</head>
<body>
省:
<select onchange="changes(this.value)">
<option value="0">河南</option>
<option value="1">山东</option>
<option value="2">山西</option>
</select>
市:
<select id="shi">

</select>
</body>
</html>

 

标签:Jquery,省市级,innerHTML,getElementById,shi,var,citys,document
来源: https://www.cnblogs.com/jck980/p/15521033.html