Skip to content
Related Articles
Open in App
Not now

Related Articles

How to set year in DatePicker ?

Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 27 Oct, 2021
Improve Article
Save Article

In this article, we are going to learn about the Datepicker in jQuery. In many forms, you can select the date and year from the calendar. Datepicker is a standard form of the input field that is used to select the date and year by just seeing the calendar. It is an interactive calendar in a specified overlay. 

When you click on any date that is mentioned in the calendar then the feedback will appear on the input text. 

Methods Used – The datepicker() method is used to create an overlay of an interactive calendar.

Approach – 

  • First, you need to create an HTML file and import the jQuery library.
  • After that, you have to write code in the script tag with the datepicker method.
  • The main task is done and it is up to you whether you want to apply CSS to your application or not.




<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <link rel="stylesheet" href=
    <script src="//"></script>
    <script src="//">
        body {
            background-color: lightgreen;
            text-align: center;
        div {
            background-color: lightgreen;
            margin-left: 85px;
    <div id="datepicker"></div>


Explanation: In the above example, we have seen how to create a calendar with just a few lines of code. If you want to select the year then you just have to click on the next arrow button in the calendar.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!