百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

city-picker

> 编程语言
开源

下拉面板式省市区三级联动jquery插件,视觉更清爽,交互体验更友好。

780 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

下拉面板式省市区三级联动jquery插件,视觉更清爽,交互体验更友好。

City Picker

A simple jQuery plugin for picking provinces, cities and districts of China.

  • Demo

##Release History

###v1.1.0 Add function to get the code:

// type: null or undefined(get the full code path, separated with /), province, city, district
$('.city-picker').data('citypicker').getCode(type);

Main

dist/
├── city-picker.js          ( 7 KB)
├── city-picker.min.js      ( 4 KB)
├── city-picker.data.js     (98 KB)
└── city-picker.data.min.js (68 KB)

Getting started

Quick start

Four quick start options are available:

  • Download the latest release.
  • Clone the repository: git clone https://github.com/tshi0912/city-picker.git.
  • Install with NPM: npm install city-picker.
  • Install with Bower: bower install city-picker.

Installation

Include files:

Create HTML elements:

Usage

Initialize with data-toggle="city-picker" attribute

Basic

Custom placeholders

Responsive width

Custom province/city/district

Initialize with $.fn.city-picker method

Basic

$('#target').citypicker();

Custom districts

$('#target').citypicker({
  province: '江苏省',
  city: '常州市',
  district: '溧阳市'
});

Options

  • Change the default options with $().citypicker(options).
  • Change the global default options with $.fn.citypicker.setDefaults(options).

simple

  • Type: Boolean
  • Default: false

Make the address level more simple, e.g. 内蒙古 instead of 内蒙古自治区.

level

  • Type: String
  • Default: district

Only province, province + city, or province + city + district.

responsive

  • Type: Boolean
  • Default: false

make the drop down and mask span responsive on width.

placeholder

  • Type: Boolean
  • Default: 请输入省/市/区

Show placeholder (with an `` element).

province

  • Type: String
  • Default: null

Defines the initial value of province. If it is a existing province in city-picker.data.js, it will be selected. If not, it will be used as a placeholder.

city

  • Type: String
  • Default: null

Defines the initial value of city. If it is a existing city under the selected province, it will be selected. If not, it will be used as a placeholder.

district

  • Type: String
  • Default: null

Defines the initial value of district. If it is a existing district under the selected city, it will be selected. If not, it will be used as a placeholder.

Methods

reset()

Reset the selects to the initial states (Undo changed).

Examples:

$().citypicker('reset');

destroy()

Destroy the city-picker instance, but keep the selected districts.

If you want to remove the selected districts, you can call reset method first and then call this method.

No conflict

If you have to use other plugin with the same namespace, just call the $.fn.city-picker.noConflict method to revert to it.

Browser support

  • Chrome (latest 2)
  • Firefox (latest 2)
  • Internet Explorer 8+
  • Opera (latest 2)
  • Safari (latest 2)

As a jQuery plugin, you also need to see the jQuery Browser Support.

License

MIT © Tao Shi

Issues· 47 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言