<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script type="text/javascript" src="../../js库/jquery-2.1.0.js"></script>
<script>
var province = [
["深圳市","东莞市","惠州市","广州市"],
["长沙市","岳阳市","株洲市","湘潭市"],
["厦门市","福州市","漳州市","泉州市"]
];
$(function(){
$("#province").change(function(){//获得事件
var city = province[this.value];
$("#city").empty();//JQ的清空方式
$(city).each(function(i,n){
$("#city").append("<option>"+n+"</option>");
});
});
});
</script>
<select id="province"><!--选择后的事件-->
<option value="-1">请选择省</option>
<option value="0">广东省</option>
<option value="1">湖南省</option>
<option value="2">福建省</option>
</select>
<select id="city">
</select>
</body>
</html>
6.3 JQ的省市联动
最新推荐文章于 2021-09-14 11:42:18 发布