This time I will share jQuery Plugin and tutorial about User-friendly Time Picker Component – tui.time-picker, hope it will help you in programming stack.
tui.time-picker is a minimal, user-friendly, multi-language time picker component written/implemented in jQuery. Supports ante meridiem (AM) and post meridiem (PM).
The plugin provides 2 ways to select times:
- Selectbox: Select hours/minutes from select dropdowns.
- Pinbox: Select hours/minutes by clicking the increment/decrement buttons.
How to use it:
1. Download & Install the tui.time-picker package via NPM.
2 |
$ npm install tui-time-picker --save |
2. Import the the tui.time-picker component.
2 |
import {TimePicker} from 'tui-time-picker'; |
3. Or include the compiled version of the tui.time-picker library on the webpage.
1 |
< link href = "/path/to/tui-time-picker.css" rel = "stylesheet" > |
2 |
< script src = "/path/to/jquery.min.js" ></ script > |
3 |
< script src = "/path/to/tui-code-snippet.min.js" ></ script > |
4 |
< script src = "/path/to/tui-time-picker.js" ></ script > |
4. Create placeholders for the time pickers.
1 |
< div id = "timepicker-selectbox" ></ div > |
2 |
< div id = "timepicker-spinbox" ></ div > |
5. Initialize the time pickers and done.
1 |
var tpSelectbox = new tui.TimePicker('#timepicker-selectbox', { |
2 |
inputType: 'selectbox' // default |
5 |
var tpSpinbox = new tui.TimePicker('#timepicker-spinbox', { |
6. Possible options to customize your time picker.
- initialHour: initial hour
- initialMinute: initial minute
- hourStep: step value of hour
- minuteStep: step value of minute
- inputType: ‘selectbox’ or ‘spinbox’
- format: custom time format
- showMeridiem: shows AM/PM
- disabledHours: an array of disabled hours
- meridiemPosition: ‘right’ or ‘left’
- language: sets locale texts
- usageStatistics: send hostname to google analytics
06 |
inputType: 'selectbox' , |
09 |
meridiemPosition: 'right' , |
7. API methods.
02 |
TimePicker.localeTexts[ 'customKey' ] = { |
08 |
TimePicker.changeLanguage() |
17 |
TimePicker.getHourStep() |
20 |
TimePicker.getMinute() |
23 |
TimePicker.getMinuteStep() |
32 |
TimePicker.setHourStep() |
35 |
TimePicker.setMinute() |
38 |
TimePicker.setMinuteStep() |
This awesome jQuery plugin is developed by nhnent. For more Advanced Usages, please check the demo page or visit the official website.