This time I will share jQuery Plugin and tutorial about Powerful Calendar Plugin With jQuery – Calendar.js, hope it will help you in programming stack.
A lightweight, fast, customizable, and easy-to-style calendar component built on top of jQuery.
Key Features:
- Switches between months with Next/Prev buttons.
- Or directly switches between months from a selector UI by clicking the year.
- Also allows you to select a year from a dropdown.
- Allows you to set min/max dates.
- Disabled dates are supported as well.
- Useful callbacks that can be useful for date picker, month picker, or year picker.
How to use it:
1. Place the main script calendar.min.js
after loading the latest jQuery library.
1 |
< script src = "/path/to/cdn/jquery.slim.min.js" ></ script > |
2 |
< script src = "/path/to/calendar.min.js" ></ script > |
2. Create a container to hold the calendar.
1 |
< div class = "calendar-container" ></ div > |
3. Call the function to generate a default calendar inside the container you just created.
2 |
$( '.calendar-container' ).calendar(); |
4. Apply CSS classes to the calendar or include the following CSS files on the page.
1 |
< link rel = "stylesheet" href = "style.css" /> |
2 |
< link rel = "stylesheet" href = "theme.css" /> |
5. Determine the date to highlight on page load.
1 |
$( '.calendar-container' ).calendar({ |
6. Set the length of names of days of the week. Default: 1.
1 |
$( '.calendar-container' ).calendar({ |
7. Disable dates using the disable
function.
1 |
$( '.calendar-container' ).calendar({ |
3 |
disable: function (date) { |
4 |
return date < new Date(); |
8. Trigger a function when a date is selected.
1 |
$( '.calendar-container' ).calendar({ |
2 |
onClickDate: function (date) { |
9. More configurations to customize the calendar.
01 |
$( '.calendar-container' ).calendar({ |
08 |
monthYearSeparator: " " , |
11 |
showThreeMonthsInARow: true , |
14 |
enableMonthChange: true , |
20 |
showTodayButton: true , |
21 |
todayButtonContent: "Today" , |
24 |
highlightSelectedWeekday: true , |
27 |
highlightSelectedWeek: true , |
30 |
showYearDropdown: false , |
10. More callback functions.
01 |
$( '.calendar-container' ).calendar({ |
03 |
onChangeMonth: function (date) {}, |
04 |
onClickToday: function (date) {}, |
05 |
onClickMonthNext: function (date) {}, |
06 |
onClickMonthPrev: function (date) {}, |
07 |
onClickYearNext: function (date) {}, |
08 |
onClickYearPrev: function (date) {}, |
09 |
onShowYearView: function (date) {}, |
10 |
onSelectYear: function (date) {}, |
Changelog:
2021-03-31
- v1.1: Added the ‘startOnMonday’ flag. This allows you to start the month on Monday instead of Sunday.
2021-03-30
- v1.0: First stable release
2021-03-26