jQuery provides a front-end calendar CLNDR plugin using HTML templates mostly used in single-day or multiple days event management system. It is used in appointing dates of various events in the calendar format. You have to download the required files in the working folder so that the programmer can include it in the head section of the HTML structure page as implemented in the following programs.
Note: Include the "underscore.js" and "moment.js" libraries in the head section, before the "clndr.js" as the CLNDR plugin leans on these libraries. . Download the link for CLNDR plugin.
Example 1: The following example demonstrates the basic usage of CLNDR plugin which displays the current month in calendar format. Options like "showAdjacentMonths" and "adjacentDaysChangeMonth" are set to true for quick and easy traverse of previous and next months.
html
<!DOCTYPE html>
<html>
<head>
<title>jQuery Calendar Plugin</title>
<meta charset="UTF-8" />
<link rel="stylesheet" href="clndr.css" />
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js">
</script>
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js">
</script>
<script src="clndr.js"></script>
<style>
body {
font-family: Arial;
text-align: center;
}
</style>
</head>
<body>
<h1 style="color: green;">
GeeksForGeeks
</h1>
<b>jQuery CLNDR Plugin</b>
<div class="container">
<div class="cal1"></div>
</div>
<script>
let calendar = {};
$(document).ready(function () {
calendar.clndr = $(".cal1").clndr({
// Able to display adjacent months
showAdjacentMonths: true,
// Visible adjacent days will show
// corresponding month on click
adjacentDaysChangeMonth: true,
});
// Going forward monthwise
calendar.forward();
// Going back to previous month
calendar.back();
});
</script>
</body>
</html>
Output :
Example 2:
The following example demonstrates passing of events for information display using the CLNDR plugin. In the jQuery code, list of events is passed to the CLNDR click event in the form of array. It displays the date in "red" color and event title in the bottom, once the event date is clicked by the user. Days of the week are also set in a particular format. Programmer can set other options depending on the application requirement.
html
<html>
<head>
<title>jQuery CLNDR Plugin</title>
<meta charset="UTF-8" />
<link rel="stylesheet" href="clndr.css" />
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js">
</script>
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js">
</script>
<script src="clndr.js"></script>
<style>
body {
font-family: Arial;
text-align: center;
}
div#eventInfoID {
margin-top: 5px;
width: 90%;
text-align: center;
font-weight: bold;
padding: 10px;
box-sizing: content-box;
}
</style>
</head>
<body>
<h1 style="color: green;">
GeeksForGeeks
</h1>
<b>jQuery CLNDR Plugin</b>
<div class="container">
<div class="cal1"></div>
<div id="eventInfoID"><b></b></div>
</div>
<script>
let calendar = {};
$(document).ready(function () {
let eventsList = [
{
date: "2020-05-08",
title: "Open lecture on web",
},
{
date: "2020-05-20",
title: "Another Long Event",
},
{
title: "Birthday Party",
date: "2020-05-27",
},
];
calendar.clndr = $(".cal1").clndr({
// Displays days of the week in given format
daysOfTheWeek: ["Sun", "Mon", "Tue",
"Wed", "Thu", "Fri", "Sat"],
events: eventsList,
clickEvents: {
click: function (target) {
$(".day .day-contents").css("color", "#000");
// Displays the event date in red, once clicked
$(".calendar-day-" + target["date"]["_i"] + " .day-contents")
.css("color", "#FF0000");
let titleInfo = target.events[0].title;
$("#eventInfoID").text(titleInfo);
},
},
showAdjacentMonths: true,
adjacentDaysChangeMonth: false,
});
});
</script>
</body>
</html>
Output :
The CLNDR plugin can also handle multiple-day events in the similar manner like single-day events by accessing
start
and
end
date of your event in the array object.
Example 3: The following example demonstrates CLNDR plugin with some constraints like choosing dates within a particular range in the calendar. It helps in handling a lot of user and date validations in web applications.
html
<!DOCTYPE html>
<html>
<head>
<title>jQuery CLNDR plugin</title>
<meta charset="UTF-8" />
<link rel="stylesheet" href="clndr.css" />
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js">
</script>
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js">
</script>
<script src="clndr.js"></script>
<style>
body {
font-family: Arial;
}
.msg-row {
padding: 5px;
}
.container {
width: 650px;
}
#constraintInfoID {
margin-top: 5px;
margin-left: 5px;
width: 600px;
text-align: center;
font-weight: bold;
padding: 10px 10px;
box-sizing: content-box;
}
</style>
</head>
<body>
<h1 style="color: green;">
GeeksForGeeks
</h1>
<b>jQuery CLNDR Plugin</b>
<div class="container">
<div id="calendarID" class="cal1"></div>
<div id="constraintInfoID"></div>
</div>
<script>
let calendar = {};
$(document).ready(function () {
calendar.clndr = $("#calendarID").clndr({
constraints: {
startDate: "2020-05-06",
endDate: "2020-05-16",
},
clickEvents: {
click: function (target) {
if (!$(target.element).hasClass("inactive")) {
let msg = "Valid date within the constraints!";
$("#constraintInfoID")
.append("<div class='msg-row'
style = 'background-color:green' > "
+ msg + "</div>");
} else {
let msg = "Date chosen is outside the constraint range";
$("#constraintInfoID")
.append("<div class='msg-row'
style = 'background-color:red' > "
+ msg + "</div>");
}
},
},
});
});
</script>
</body>
</html>
Output:
Similar Reads
jQuery Page Piling Plugin jQuery pagePiling.js plug-in is a rich feature available for programmers for piling more than one layout section, one over the other, and accessing each page by URL or mouse scrolling or side bullets navigation. This feature provides all type of smooth vertical, horizontal, and side navigations to t
5 min read
jQuery | Flickerplate Plugin jQuery provides Flickerplate plugin that helps our programmers to create sliders for websites that can cycle through a list of background images along with dot navigation feature and animated arrows. The plugin consists of many more libraries that are responsible for touch detections and events such
5 min read
jQuery Multiscroll Plugin jQuery provides multiscroll.js plugin which helps programmers to create split web pages along with divided multiple vertical scrolling panels.Note: Please download the jQuery multiscroll plugin to your working folder and include the required files in the head section of your code as shown below. Dow
3 min read
jQuery RowGrid Plugin jQuery provides a very simple, user-friendly and responsive rowGrid plugin that helps programmers to display images in a straight row. It is very lightweighted and supports infinite scrolling feature. Real examples of rowGrid are Google+ images or Google image search that appears in a straight row g
4 min read
jQuery Alertify Plugin jQuery framework provides alertify.js plugin that provides pre-designed customizable notification system along with interactive browser dialogs. This extensible and themeable plugin is very useful for developers providing an optimized version of alert messages with stacking up to feature. This small
5 min read
jQuery Image ProgressBars Plugin In this article, we will learn how to implement image ProgressBar feature using the jQuery Image ProgressBar plugin. Note: Please download the jQuery Image ProgressBar plugin in the working folder and include the required files in the head section of your HTML code. <link href=âprogressbar.cssâ r
2 min read
jQuery DrawSVG Plugin SVG or Scalar Vector Graphics is Extended Markup Language-based graphics supporting 2 dimensional animations of images enhancing interactiveness. The specifications of SVG are open standards by World Wide Web Consortium defined in XML text files. These files can be changed or created with any drawin
4 min read
jQuery Tagsort Plugin jQuery provides Tagsort plugin that is used for displaying tags or filter elements based on different tags in a DOM. The plugin takes data-attributes of HTML page structure and dynamically creates user-friendly tags used for filtering elements. The filtration of elements are done in many ways that a
9 min read
jQuery Logos Distort Plugin The jQuery provides LogosDistort plugin which helps in creating or animating a parallax environment for 3D scenes in the user browser. It uses full-page matrix3D perspective logos distortions for transforming base on mouse movement. You have to download the required files in the working folder so th
4 min read
jQuery Filer Plugin jQuery provides a quick jQuery Filer uploader plugin for easy implementation of uploading the files. It provides features like instant uploading of files, file append, file removal, multiple selections, drag and drop support along with other file validations.Download the required files to include it
2 min read