jquery省份城市选择器

var pro = ["北京","天津","上海","重庆","河北","山西","辽宁","吉林","黑龙江","江苏","浙江","安徽","福建","江 西","山东","河南","湖北","湖南","广东","海南","四川","贵州","云南","陕西","甘肃","青海","内蒙古","广 西","西藏","宁夏","新疆维吾尔自治区","香港","澳门","台湾"];

var city =
{北京:["东城区","西城区","崇文区","宣武区","朝阳区","海淀区","丰台区","石景山区","房山区","通州区","顺义
区","昌平区","大兴区","怀柔区","平谷区","门头沟区","密云县","延庆县"],天津:["和平区","河东区","河西区","南开
区","河北区","红桥区","东丽区","西青区","北辰区","津南区","武清区","宝坻区","滨海新区","静海县","宁河县","蓟
县"],上海:["黄浦区","卢湾区","徐汇区","长宁区","静安区","普陀区","闸北区","虹口区","杨浦区","闵行区","宝山
区","嘉定区","浦东新区","金山区","松江区","青浦区","奉贤区","崇明县"],重庆:["渝中区","大渡口区","江北区","南
岸区","北碚区","渝北区","巴南区","长寿区","双桥区","沙坪坝区","万盛区","万州区","涪陵区","黔江区","永川区","
合川区","江津区","九龙坡区","南川区","綦江县","潼南县","荣昌县","璧山县","大足县","铜梁县","梁平县","开县","
忠县","城口县","垫江县","武隆县","丰都县","奉节县","云阳县","巫溪县","巫山县","石柱土家族自治县","秀山土家族苗族自
治县","酉阳土家族苗族自治县","彭水苗族土家族自治县"],河北:["石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家
口","承德","沧州","廊坊","衡水"],山西:["太原","大同","阳泉","长治","晋城","朔州","晋中","运城","忻
州","临汾","吕梁"],辽宁:["沈阳","大连","鞍山","抚顺","本溪","丹东","锦州","营口","阜新","辽阳","盘
锦","铁岭","朝阳","葫芦岛"],吉林:["长春","吉林","四平","辽源","通化","白山","松原","白城","延边朝鲜族自治
州"],黑龙江:["哈尔滨","齐齐哈尔","鹤岗","双鸭山","鸡西","大庆","伊春","牡丹江","佳木斯","七台河","黑河","
绥化","大兴安岭"],江苏:["南京","苏州","无锡","常州","镇江","南通","泰州","扬州","盐城","连云港","徐
州","淮安","宿迁"],浙江:["杭州","宁波","温州","嘉兴","湖州","绍兴","金华","衢州","舟山","台州","丽
水"],安徽:["合肥","芜湖","蚌埠","淮南","马鞍山","淮北","铜陵","安庆","黄山","滁州","阜阳","宿州","巢
湖","六安","亳州","池州","宣城"],福建:["福州","厦门","莆田","三明","泉州","漳州","南平","龙岩","宁
德"],江西:["南昌","景德镇","萍乡","九江","新余","鹰潭","赣州","吉安","宜春","抚州","上饶"],山东:["济
南","青岛","淄博","枣庄","东营","烟台","潍坊","济宁","泰安","威海","日照","莱芜","临沂","德州","聊
城","滨州","菏泽"],河南:["郑州","开封","洛阳","平顶山","安阳","鹤壁","新乡","焦作","濮阳","许昌","漯
河","三门峡","南阳","商丘","信阳","周口","驻马店"],湖北:["武汉","黄石","十堰","荆州","宜昌","襄樊","鄂
州","荆门","孝感","黄冈","咸宁","随州","恩施"],湖南:["长沙","株洲","湘潭","衡阳","邵阳","岳阳","常
德","张家界","益阳","郴州","永州","怀化","娄底","湘西"],广东:["广州","深圳","珠海","汕头","韶关","佛
山","江门","湛江","茂名","肇庆","惠州","梅州","汕尾","河源","阳江","清远","东莞","中山","潮州","揭
阳","云浮"],海南:["海口","三亚"],四川:["成都","自贡","攀枝花","泸州","德阳","绵阳","广元","遂宁","内
江","乐山","南充","眉山","宜宾","广安","达州","雅安","巴中","资阳","阿坝","甘孜","凉山"],贵州:["贵
阳","六盘水","遵义","安顺","铜仁","毕节","黔西南","黔东南","黔南"],云南:["昆明","曲靖","玉溪","保山","
昭通","丽江","普洱","临沧","德宏","怒江","迪庆","大理","楚雄","红河","文山","西双版纳"],陕西:["西安","
铜川","宝鸡","咸阳","渭南","延安","汉中","榆林","安康","商洛"],甘肃:["兰州","嘉峪关","金昌","白银","天
水","武威","酒泉","张掖","庆阳","平凉","定西","陇南","临夏","甘南"],青海:["西宁","海东","海北","海
南","黄南","果洛","玉树","海西"],内蒙古:["呼和浩特","包头","乌海","赤峰","通辽","鄂尔多斯","呼伦贝尔","巴
彦淖尔","乌兰察布","锡林郭勒盟","兴安盟","阿拉善盟"],广西:["南宁","柳州","桂林","梧州","北海","防城港","钦
州","贵港","玉林","百色","贺州","河池","来宾","崇左"],西藏:["拉萨","那曲","昌都","林芝","山南","日喀
则","阿里"],宁夏:["银川","石嘴山","吴忠","固原","中卫"],新疆维吾尔自治区:["乌鲁木齐","克拉玛依","吐鲁番","哈
密","和田","阿克苏","喀什","克孜勒苏","巴音郭楞","昌吉","博尔塔拉","伊犁","塔城","阿勒泰"],香港:["香港
岛","九龙东","九龙西","新界东","新界西"],澳门:["澳门半岛","离岛"],台湾:["台北","高雄","基隆","新竹","台
中","嘉义","台南市"]};
$(document).ready(function(){
for(var i=0;i<pro.length;i++){
$option=$("<option/>")
$option.attr("value",pro[i]);
$option.text(pro[i]);
$(".province").append($option);
}
$(".province").click(function(){
var cities=city[$(this).val()];
$(this).parent().find(".city").empty();
for(var i=0;i<cities.length;i++){
$option=$("<option/>")
$option.attr("value",cities[i]);
$option.text(cities[i]);
$(this).parent().find(".city").append($option);
}
});
});

时间: 2024-10-11 09:44:56

jquery省份城市选择器的相关文章

jquery城市选择器

jquery.citypicker(自己写的jQuery中国城市选择器) *@QQ:164068300 * @版本 jquery.citypicker.js(version="1.1.0") * @使用方法: * 1.jquery.citypicker就jquery插件,使用此插件前必须先引用jquery.js库文件 * 2.再引用此库文件,引用方式:<script type="text/javascript" src="jquery.citypic

IOS开发之自制城市选择器(省份+城市+区/县城)(storyboard版)

第一步:新建single工程CitySelectedDemo 第二步:导入资源area.plist(千万勾选copy选项,后面附area.plist文件资源) 第三步:设计mian.storyboard ——>拖拽UITextField控件(运行后点击此输入框会弹出选择器,选择我们想要的城市地址后结果显示在输入框中): ——>拖拽Toolbar控件和UIPickerView控件组成城市选择器:(将Toolbar控件的Item更名为“完成”,将来点击“完成”按钮结束地址的选择,如果“完成”按钮在

UIPickerView的简单应用——省份/城市选择的实现

UIPickerView的简单应用--省份/城市选择的实现 实现效果如图,左边为省份选择,右边选择省份对应的城市 数据plist形式如图 工程下载地址:工程下载 https://github.com/Nongchaozhe/UIPickerView-Province-city UIPickerView的实现重要还是两个代理协议中方法的实现 - (void)viewDidLoad { [super viewDidLoad]; [self loadData]; _pickView = [[UIPic

UIPickerView简单应用——省份/城市选择实现

UIPickerView的简单应用--省份/城市选择的实现 实现效果如图,左边为省份选择,右边选择省份对应的城市 数据plist形式如图 工程下载地址:工程下载 https://github.com/Nongchaozhe/UIPickerView-Province-city UIPickerView的实现重要还是两个代理协议中方法的实现 - (void)viewDidLoad { [super viewDidLoad]; [self loadData]; _pickView = [[UIPic

基于jquery的城市选择插件

城市选择插件的难度不是很大,主要是对dom节点的操作.而我写的这个插件相对功能比较简答,没有加入省市联动. 上代码好了,参照代码的注释应该比较好理解. 1 /* 2 *基于jquery的城市选择插件 3 *author:youziclub 4 *2015-4-22 5 */ 6 ;(function($){ 7 $.fn.city=function(options){ 8 // 城市信息 9 var nav=['热门','A-G','H-L','M-T','W-Z','其他']; 10 var

jQuery中的选择器

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <!DOCTYPE html PUBLIC "-//W3C//DTD

jQuery基础知识--选择器与效果

$(this).hide()-----隐藏当前元素 $("p").hide()------隐藏所有段落 $(".test").hide()--隐藏所有class="test"的元素 $("#test").hide()--隐藏所有id="test"的元素 文档就绪函数 $(document).ready(function() {     ---------jQuery function go here----

非常easy学习的JQuery库 : (二) 选择器

作用 选择器同意您对元素组或单个元素进行操作. 在前面的章节中,我们介绍了一些有关怎样选取 HTML 元素的实例. 关键点是学习 jQuery 选择器是怎样准确地选取您希望应用效果的元素. jQuery 元素选择器和属性选择器同意您通过标签名.属性名或内容对 HTML 元素进行选择. 选择器同意您对 HTML 元素组或单个元素进行操作. 在 HTML DOM 术语中: 选择器同意您对 DOM 元素组或单个 DOM 节点进行操作. 元素选择器 jQuery 使用 CSS 选择器来选取 HTML 元

hotCity 小程序城市选择器, 城市数据库可自己导出

hotCity 城市选择器, 城市数据库可自己导出 后台数据API 由HotApp小程序统计提供并维护,如果需要导出并部署在公司的生产环境,最后有SQL导出下载地址 开源地址 https://github.com/hotapp888/hotcity 使用方法 复制pages/district到你的项目目录 把样式文件district.wxss引入到您调用本插件的作用域 @import "你的路径/district/wxParse.wxss"; 在需要使用的模版的x.wxml中引入模版文