A simple jQuery plugin for picking provinces, cities and districts of China.
##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);
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)
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
.
Include files:
<script src="/path/to/jquery.js"></script><!-- jQuery is required -->
<script src="/path/to/city-picker.data.js"></script>
<script src="/path/to/city-picker.js"></script>
Create HTML elements:
<div style="position:relative;"><!-- container -->
<input readonly type="text">
</div>
Basic
<div style="position:relative;">
<input readonly type="text" data-toggle="city-picker">
</div>
Custom placeholders
<div style="position:relative;">
<input readonly type="text" data-toggle="city-picker" placeholder="customized placeholder...">
</div>
Responsive width
<div style="position:relative;">
<input readonly type="text" data-toggle="city-picker" data-responsive="true" style="width:50%;">
</div>
Custom province/city/district
<div style="position:relative;">
<input readonly type="text" data-toggle="city-picker" value="江苏省/常州市/溧阳市">
</div>