This time I will share jQuery Plugin and tutorial about Inline Week Day Picker Plugin – jQuery weekdays, hope it will help you in programming stack.
A small yet configurable week day picker plugin that enables the visitor to select the day(s) of the week from a group of inline buttons.
How to use it:
1. Import jQuery library together with the JavaScript jquery-weekdays.js
and stylesheet jquery-weekdays.css
into the html file.
1 |
< link href = "src/jquery-weekdays.css" rel = "stylesheet" /> |
3 |
integrity = "sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" |
4 |
crossorigin = "anonymous" > |
6 |
< script src = "src/jquery-weekdays.js" ></ script > |
2. Create a container element to place the week day picker.
1 |
< div id = "weekdays" > </ div > |
3. The JavaScript to generate a basic week day picker on the page.
2 |
$( '#weekdays' ).weekdays(); |
4. Define an array of pre-selected days. 0 = Sunday.
2 |
$( '#weekdays' ).weekdays({ |
3 |
selectedIndexes: [0, 2, 4, 6] |
5. Enable the single selection mode.
2 |
$( '#weekdays' ).weekdays({ |
6. Default CSS selectors.
2 |
$( '#weekdays' ).weekdays({ |
3 |
listClass: 'weekdays-list' , |
4 |
itemClass: 'weekdays-day' , |
5 |
itemSelectedClass : 'weekday-selected' |
7. Localize the week day picker.
2 |
$( '#weekdays' ).weekdays({ |
3 |
days: [ "Domingo" , "Segunda" , "Terça" , "Quarta" , "Quinta" , "Sexta" , "Sábado" ] |
8. Get the selected day(s).
2 |
$( '#weekdays' ).selectedIndexes(); |
7 |
$( '#weekdays' ).selectedDays(); |
Changelog:
2019-07-05
- fixing a bug in pre-selected items
This awesome jQuery plugin is developed by nikolasmagno. For more Advanced Usages, please check the demo page or visit the official website.