地址数据来自于数据库(业务需要,地址可修改),数据库的设计:
其中pid为父节点id,lft,rgt为当前节点的子节的id范围。
数据形式:
{"area":[{"id":366,"name":"北京","pid":1,"lft":2,"rgt":5},{"id":386,"name":"天津","pid":1,"lft":6,"rgt":9},{"id":406,"name":"河北","pid":1,"lft":10,"rgt":35},{"id":568,"name":"山西","pid":1,"lft":36,"rgt":59},{"id":1121,"name":"浙江","pid":1,"lft":196,"rgt":219},{"id":1208,"name":"安徽","pid":1,"lft":220,"rgt":255},{"id":1303,"name":"福建","pid":1,"lft":256,"rgt":275},{"id":1383,"name":"江西","pid":1,"lft":276,"rgt":299},{"id":1485,"name":"山东","pid":1,"lft":300,"rgt":335},{"id":1612,"name":"河南","pid":1,"lft":336,"rgt":371},{"id":1760,"name":"湖北","pid":1,"lft":372,"rgt":409},{"id":1851,"name":"湖南","pid":1,"lft":410,"rgt":439},{"id":3019,"name":"新疆","pid":1,"lft":758,"rgt":791},{"id":3268,"name":"重庆","pid":1,"lft":792,"rgt":795}]}
效果:
引用文件:jquery-1.11.3.js,Bootstrap3.35,Bootstrap-select1.7.2
下载:
下载:
下载:
页面:
js: