HTML/Html-practice/Ajax/基于jQuery的AJAX实现三级联动菜单/index.html

52 lines
1.4 KiB
HTML
Raw Normal View History

2023-05-01 19:37:40 +08:00
<!DOCTYPE html>
<html lang="en">
2023-05-01 22:22:17 +08:00
2023-05-01 19:37:40 +08:00
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
2023-05-01 22:22:17 +08:00
<link href="./css/index.css" rel="stylesheet" type="text/css" />
2023-05-01 19:37:40 +08:00
<script src="./js/index.js"></script>
<title>基于jQuery的AJAX实现三级联动菜单</title>
</head>
2023-05-01 22:22:17 +08:00
2023-05-01 19:37:40 +08:00
<body>
<div>
<form>
省份:
2023-05-01 21:33:04 +08:00
<select name="province" id="province">
2023-05-01 19:37:40 +08:00
<option value="0">--请选择--</option>
</select>&nbsp;&nbsp; 城市:
2023-05-01 21:33:04 +08:00
<select name="city" id="city">
2023-05-01 19:37:40 +08:00
<option value="0">--请选择--</option>
</select>&nbsp;&nbsp; 地区:
<select name="area" id="area">
<option value="0">--请选择--</option>
</select>
</form>
</div>
</body>
2023-05-01 20:26:29 +08:00
<script>
2023-05-01 22:22:17 +08:00
$(function () {
2023-05-01 20:26:29 +08:00
getCountry();
2023-05-01 22:22:17 +08:00
$("#province").change(function () {
CountryId = $("#province").val();
2023-05-01 21:33:04 +08:00
// console.log(FatherId);
getCity(CountryId);
2023-05-01 22:22:17 +08:00
CityID = $("#city").val();
2023-05-01 21:47:33 +08:00
// console.log(CityID);
2023-05-01 21:33:04 +08:00
getArea(CityID);
2023-05-01 22:22:17 +08:00
2023-05-01 21:33:04 +08:00
});
2023-05-01 22:22:17 +08:00
$("#city").change(function () {
CityID = $("#city").val();
2023-05-01 21:47:33 +08:00
// console.log(CityID);
getArea(CityID);
})
2023-05-01 21:33:04 +08:00
2023-05-01 20:26:29 +08:00
})
</script>
2023-05-01 22:22:17 +08:00
2023-05-01 19:37:40 +08:00
</html>