function get(id,callback) { $.get(APP.PATH+"/sysRegions/find?id="+id,function(data){ callback(data); }) } //下一个级别 function nextLeve(leve) { var tmp = leve.substring(leve.length-1); var intTmp = parseInt(tmp)+1; return intTmp; } //移除当前列表的后续选项 function remove(leve) { var max = 3; var nextLeveInt = nextLeve(leve); for(var i=nextLeveInt;i<=max;i++) { $("#leve"+i).children().first().nextAll().remove(); } } function handler(data,leveName) { var leve =data==null ? [] : data.records; var nextLeveInt = nextLeve(leveName); if(leve!=null && leve.length>0) { remove(leveName); for(var i=0;i"+leve[i].name+"") } } } function handlerSelect(data,leveName,selectedId) { //console.log(leveName,selectedId) //if(selectedId===undefined)return; var leve =data==null ? [] : data.records; var nextLeveInt = nextLeve(leveName); if(leve!=null && leve.length>0) { remove(leveName); for(var i=0;i"+leve[i].name+"") } } } $(function(){ $(".leve").bind("change",function(){ var leveId = $(this).attr("id"); var leves = ["leve1","leve2","leve3"]; var thisVal = $(this).val(); var ZERO = "0"; if((leveId === leves[0] || leveId===leves[1]) &&thisVal===ZERO){ remove(leveId); }else{ //获取数据 get(thisVal,function(data){ handler(data,leveId); }) } }); })