jquery.cityselect.js基于jQuery+JSON的省市联动效果
直接调用
二级联动,默认选项为:请选择
三级联动,默认省份:北京,隐藏无数据的子级select
$("#city_1").citySelect({nodata:"none",required:false}); $("#city_2").citySelect({prov:"北京",nodata:"none"});
设置省份、城市、地区(县)的默认值
二级联动
三级联动
$("#city_3").citySelect({prov:"湖南", city:"长沙"}); $("#city_4").citySelect({prov:"湖南", city:"长沙", dist:"岳麓区"});
自定义下拉选项
$("#city_5").citySelect({ data:{"citylist":[ {"p":"前端技术","c":[{"n":"HTML"},{"n":"CSS","a":[{"s":"CSS2.0"},{"s":"CSS3.0"}]},{"n":"JAVASCIPT"}]}, {"p":"编程语言","c":[{"n":"C"},{"n":"C++"},{"n":"Objective-C"},{"n":"PHP"},{"n":"JAVA"}]}, {"p":"数据库","c":[{"n":"Mysql"},{"n":"SqlServer"},{"n":"Oracle"},{"n":"DB2"}]}, ]}, prov:"", city:"", dist:"", nodata:"none" });