首页 > 代码库 > jquery 城市三级联动

jquery 城市三级联动

js代码

/*城市三级联动* @method cityChange* @param allProvince,allCity,allDistrict*/function cityChange(provinceN,cityN,districtN){    var all_province="";    for(var i=0;i<allCity.province.length;i++){            all_province+=‘<option name="province" value=http://www.mamicode.com/‘+allCity.province[i].id+‘>

 

HTML代码

<!doctype html><html><head>    <meta charset="utf-8">    <title>城市三级联动</title></head><body>	<label>三级联动</label>	<div>        <select  id="allProvince">            <option value="">请选择省份</option>        </select>        <select  id="allCity" >            <option value="">请选择城市</option>        </select>        <select  id="allDistrict">            <option value="">请选择区县</option>        </select>             	</div>	<script src="http://cdn.bootcss.com/jquery/2.0.1/jquery.js"></script><script src="http://www.mamicode.com/allcity.js"></script><script src="http://www.mamicode.com/citychange.js"></script><script>	$(function(){cityChange(‘allProvince‘,‘allCity‘,‘allDistrict‘);})</script></body></html>

 源码下载地址==》下载

jquery 城市三级联动