# Distpicker
[](https://www.npmjs.com/package/distpicker) [](https://www.npmjs.com/package/distpicker)
> A simple jQuery plugin for picking provinces, cities and districts of China.
- [Website](https://fengyuanchen.github.io/distpicker)
> 请注意以下市/县并未设置下一级的区/乡/镇:济源市、潜江市、神农架林区、天门市、仙桃市、东莞市、中山市、东沙群岛、白沙黎族自治县、保亭黎族苗族自治县、昌江黎族自治县、澄迈县、儋州市、定安县、东方市、乐东黎族自治县、临高县、陵水黎族自治县、琼海市、琼中黎族苗族自治县、屯昌县、万宁市、文昌市、五指山市、嘉峪关市、阿拉尔市、北屯市、可克达拉市、昆玉市、石河子市、双河市、铁门关市、图木舒克市、五家渠市。
## Table of contents
- [Main](#main)
- [Getting started](#getting-started)
- [Options](#options)
- [Methods](#methods)
- [No conflict](#no-conflict)
- [Browser support](#browser-support)
- [License](#license)
## Main
```text
dist/
├── distpicker.js (UMD)
├── distpicker.min.js (UMD, compressed)
├── distpicker.common.js (CommonJS, default)
└── distpicker.esm.js (ES Module)
```
## Getting started
### Install
```shell
npm install distpicker
```
Include files:
```html
```
Create HTML elements:
```html
```
### Usage
#### Initialize with `data-toggle="distpicker"` attribute
Basic
```html
```
Custom placeholders
```html
```
Custom districts
```html
```
#### Initialize with `$.fn.distpicker` method
Basic
```js
$('#target').distpicker();
```
Custom placeholders
```js
$('#target').distpicker({
province: '---- 所在省 ----',
city: '---- 所在市 ----',
district: '---- 所在区 ----'
});
```
Custom districts
```js
$('#target').distpicker({
province: '浙江省',
city: '杭州市',
district: '西湖区'
});
```
[⬆ back to top](#table-of-contents)
## Options
- Change the default options with `$().distpicker(options)`.
- Change the global default options with `$.fn.distpicker.setDefaults(options)`.
Also supports to set the options by `data-*` attributes:
```html
...
```
### autoselect
- Type: `Number`
- Options:
- `0`: Disable autoselect.
- `1`: Autoselect province only.
- `2`: Autoselect province and city only.
- `3`: Autoselect all (province, city and district).
- Default: `0`
Selects the districts automatically.
### placeholder
- Type: `Boolean`
- Default: `true`
Show placeholder (with an `