diff --git a/Html-practice/Ajax/基于jQuery的AJAX实现三级联动菜单/index.html b/Html-practice/Ajax/基于jQuery的AJAX实现三级联动菜单/index.html
index c92cf06..4a52a95 100644
--- a/Html-practice/Ajax/基于jQuery的AJAX实现三级联动菜单/index.html
+++ b/Html-practice/Ajax/基于jQuery的AJAX实现三级联动菜单/index.html
@@ -34,9 +34,15 @@
// console.log(FatherId);
getCity(CountryId);
CityID=$("#city").val();
- console.log(CityID);
+ // console.log(CityID);
getArea(CityID);
+
});
+ $("#city").change(function(){
+ CityID=$("#city").val();
+ // console.log(CityID);
+ getArea(CityID);
+ })
})
diff --git a/Html-practice/Ajax/基于jQuery的AJAX实现三级联动菜单/js/index.js b/Html-practice/Ajax/基于jQuery的AJAX实现三级联动菜单/js/index.js
index 90bda0b..f421c5f 100644
--- a/Html-practice/Ajax/基于jQuery的AJAX实现三级联动菜单/js/index.js
+++ b/Html-practice/Ajax/基于jQuery的AJAX实现三级联动菜单/js/index.js
@@ -16,16 +16,7 @@ function getData(){
}
-function getCountry(){
- // $.ajax({
- // url : './json/third-level-address.json',
- // type : 'get',
- // async: false,
- // success : function(data) {
- // if(data=="error"){
- // alert("系统错误");
- // return;
- // }
+function getCountry(){
var data = getData();
var country = new Array();
var children = new Array();
@@ -36,9 +27,8 @@ function getCountry(){
children.push(tmp.children);
});
// for(var i in data){
- // console.log(data[i].children[0].children[0].code);
+ // console.log(data[i].children[0].children.length);
// }
- // console.log(data[0].children[1].name);
var options = "";
for(var i in data){
options += "";
@@ -52,9 +42,12 @@ function getCity(countryCode){
$('#city').empty();
var options = "";
for(var i in data){
- if(countryCode && countryCode == data[i].code){
- options += "";
+ for(let j=0;j" + data[i].children[j].name+"";
}
+
+ }
$("#city").html(options);
}
@@ -63,9 +56,13 @@ function getArea(cityCode){
var data = getData();
var options = "";
for(var i in data){
- if(cityCode && cityCode == data[i].children[0].code){
- options += "";
- }
+ for(let j=0;j" + data[i].children[j].children[k].name+"";
+ }
+ }
+}
$("#area").html(options);
}