{"id":15029604,"url":"https://github.com/fengyuanchen/distpicker","last_synced_at":"2025-05-15T00:09:37.236Z","repository":{"id":13080114,"uuid":"15761111","full_name":"fengyuanchen/distpicker","owner":"fengyuanchen","description":"⚠️ [Deprecated] No longer maintained. A simple jQuery plugin for picking provinces, cities and districts of China. (中国 / 省市区 / 三级联动 / 地址选择器)","archived":false,"fork":false,"pushed_at":"2023-01-01T10:54:31.000Z","size":898,"stargazers_count":1638,"open_issues_count":3,"forks_count":460,"subscribers_count":71,"default_branch":"master","last_synced_at":"2025-04-06T16:09:34.520Z","etag":null,"topics":["china","district","jquery-plugin","picker"],"latest_commit_sha":null,"homepage":"https://fengyuanchen.github.io/distpicker/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fengyuanchen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-09T08:37:07.000Z","updated_at":"2025-03-17T02:30:43.000Z","dependencies_parsed_at":"2022-07-12T15:08:14.941Z","dependency_job_id":null,"html_url":"https://github.com/fengyuanchen/distpicker","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengyuanchen%2Fdistpicker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengyuanchen%2Fdistpicker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengyuanchen%2Fdistpicker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengyuanchen%2Fdistpicker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fengyuanchen","download_url":"https://codeload.github.com/fengyuanchen/distpicker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248781276,"owners_count":21160705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["china","district","jquery-plugin","picker"],"created_at":"2024-09-24T20:11:10.972Z","updated_at":"2025-04-13T20:38:43.780Z","avatar_url":"https://github.com/fengyuanchen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Distpicker\n\n[![Downloads](https://img.shields.io/npm/dm/distpicker.svg)](https://www.npmjs.com/package/distpicker) [![Version](https://img.shields.io/npm/v/distpicker.svg)](https://www.npmjs.com/package/distpicker) [![Gzip Size](https://img.shields.io/bundlephobia/minzip/distpicker.svg)](https://unpkg.com/distpicker/dist/distpicker.common.js)\n\n\u003e A simple jQuery plugin for picking provinces, cities and districts of China.\n\n- [Website](https://fengyuanchen.github.io/distpicker)\n\n\u003e 请注意以下市/县并未设置下一级的区：济源市、潜江市、神农架林区、天门市、仙桃市、东莞市、中山市、东沙群岛、白沙黎族自治县、保亭黎族苗族自治县、昌江黎族自治县、澄迈县、儋州市、定安县、东方市、乐东黎族自治县、临高县、陵水黎族自治县、琼海市、琼中黎族苗族自治县、屯昌县、万宁市、文昌市、五指山市、嘉峪关市、阿拉尔市、北屯市、可克达拉市、昆玉市、石河子市、双河市、铁门关市、图木舒克市、五家渠市。\n\n## Table of contents\n\n- [Main](#main)\n- [Getting started](#getting-started)\n- [Options](#options)\n- [Methods](#methods)\n- [No conflict](#no-conflict)\n- [Browser support](#browser-support)\n- [License](#license)\n\n## Main files\n\n```text\ndist/\n├── distpicker.js        (UMD)\n├── distpicker.min.js    (UMD, compressed)\n├── distpicker.common.js (CommonJS, default)\n└── distpicker.esm.js    (ES Module)\n```\n\n## Getting started\n\n### Install\n\n```shell\nnpm install distpicker\n```\n\nInclude files:\n\n```html\n\u003cscript src=\"/path/to/jquery.js\"\u003e\u003c/script\u003e\u003c!-- jQuery is required --\u003e\n\u003cscript src=\"/path/to/distpicker.js\"\u003e\u003c/script\u003e\n```\n\nCreate HTML elements:\n\n```html\n\u003cdiv\u003e\u003c!-- container --\u003e\n  \u003cselect\u003e\u003c/select\u003e\u003c!-- province --\u003e\n  \u003cselect\u003e\u003c/select\u003e\u003c!-- city --\u003e\n  \u003cselect\u003e\u003c/select\u003e\u003c!-- district --\u003e\n\u003c/div\u003e\n```\n\n### Usage\n\n#### Initialize with `data-toggle=\"distpicker\"` attribute\n\nBasic\n\n```html\n\u003cdiv data-toggle=\"distpicker\"\u003e\n  \u003cselect\u003e\u003c/select\u003e\n  \u003cselect\u003e\u003c/select\u003e\n  \u003cselect\u003e\u003c/select\u003e\n\u003c/div\u003e\n```\n\nCustom placeholders\n\n```html\n\u003cdiv data-toggle=\"distpicker\"\u003e\n  \u003cselect data-province=\"---- 选择省 ----\"\u003e\u003c/select\u003e\n  \u003cselect data-city=\"---- 选择市 ----\"\u003e\u003c/select\u003e\n  \u003cselect data-district=\"---- 选择区 ----\"\u003e\u003c/select\u003e\n\u003c/div\u003e\n```\n\nCustom districts\n\n```html\n\u003cdiv data-toggle=\"distpicker\"\u003e\n  \u003cselect data-province=\"浙江省\"\u003e\u003c/select\u003e\n  \u003cselect data-city=\"杭州市\"\u003e\u003c/select\u003e\n  \u003cselect data-district=\"西湖区\"\u003e\u003c/select\u003e\n\u003c/div\u003e\n```\n\n#### Initialize with `$.fn.distpicker` method\n\nBasic\n\n```js\n$('#target').distpicker();\n```\n\nCustom placeholders\n\n```js\n$('#target').distpicker({\n  province: '---- 所在省 ----',\n  city: '---- 所在市 ----',\n  district: '---- 所在区 ----'\n});\n```\n\nCustom districts\n\n```js\n$('#target').distpicker({\n  province: '浙江省',\n  city: '杭州市',\n  district: '西湖区'\n});\n```\n\n[⬆ back to top](#table-of-contents)\n\n## Options\n\n- Change the default options with `$().distpicker(options)`.\n- Change the global default options with `$.fn.distpicker.setDefaults(options)`.\n\nAlso supports to set the options by `data-*` attributes:\n\n```html\n\u003cdiv data-toggle=\"distpicker\" data-autoselect=\"3\" data-province=\"浙江省\"\u003e...\u003c/div\u003e\n```\n\n### autoselect\n\n- Type: `Number`\n- Options:\n  - `0`: Disable autoselect.\n  - `1`: Autoselect province only.\n  - `2`: Autoselect province and city only.\n  - `3`: Autoselect all (province, city and district).\n- Default: `0`\n\nSelects the districts automatically.\n\n### placeholder\n\n- Type: `Boolean`\n- Default: `true`\n\nShow placeholder (with an `\u003coption\u003e` element).\n\n### valueType\n\n- Type: `String`\n- Options:\n  - `'name'`: administrative division name.\n  - `'code'`: administrative division code.\n- Default: `'name'`\n\nDefines the value type of the `\u003cselect\u003e` element.\n\nNote that this option in `data-*` attribute should be `data-value-type`:\n\n```html\n\u003cdiv data-toggle=\"distpicker\" data-value-type=\"code\"\u003e...\u003c/div\u003e\n```\n\n### province\n\n- Type: `String`\n- Default: `—— 省 ——`\n\nDefines the initial value of province `\u003cselect\u003e`. If it is a valid province, it will be selected. If not, it will be used as a placeholder.\n\n### city\n\n- Type: `String`\n- Default: `—— 市 ——`\n\nDefines the initial value of city `\u003cselect\u003e`. If it is a valid city under the selected province, it will be selected. If not, it will be used as a placeholder.\n\n### district\n\n- Type: `String`\n- Default: `—— 区 ——`\n\nDefines the initial value of district `\u003cselect\u003e`. If it is a valid district under the selected city, it will be selected. If not, it will be used as a placeholder.\n\n[⬆ back to top](#table-of-contents)\n\n## Methods\n\n### getDistricts([districtCode])\n\n- **districtCode** (optional):\n  - Type: `Number`\n  - The district code of target country, province or city.\n  - If not present, will return all the districts.\n\n- (return value):\n  - Type: `Object`\n\nGet districts data.\n\n```js\n$().distpicker('getDistricts'); // 中国\n$().distpicker('getDistricts', 330000); // 浙江省\n$().distpicker('getDistricts', 330100); // 杭州市\n```\n\n### reset([deep])\n\n- **deep** (optional):\n  - Type: `Boolean`\n  - Default: `false`\n  - Reset the selects to default states (Undo selected).\n\nReset the selects to the initial states (Undo changed).\n\n```js\n$().distpicker('reset');\n$().distpicker('reset', true);\n```\n\n### destroy()\n\nDestroy the distpicker instance, but keep the selected districts.\n\nIf you want to remove the selected districts, you can call `reset` method first and then call this method.\n\n[⬆ back to top](#table-of-contents)\n\n## No conflict\n\nIf you have to use other plugin with the same namespace, just call the `$.fn.distpicker.noConflict` method to revert to it.\n\n```html\n\u003cscript src=\"other-plugin.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"distpicker.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  $.fn.distpicker.noConflict();\n  // Code that uses other plugin's \"$().distpicker\" can follow here.\n\u003c/script\u003e\n```\n\n## Browser support\n\n- Chrome (latest)\n- Firefox (latest)\n- Safari (latest)\n- Opera (latest)\n- Edge (latest)\n- Internet Explorer 9+\n\nAs a jQuery plugin, you also need to see the [jQuery Browser Support](https://jquery.com/browser-support/).\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT) © [Chen Fengyuan](https://chenfengyuan.com/)\n\n[⬆ back to top](#table-of-contents)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffengyuanchen%2Fdistpicker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffengyuanchen%2Fdistpicker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffengyuanchen%2Fdistpicker/lists"}