How to highlight specific dates with custom styles in jQuery UI Datepicker

0 votes
Can you tell me How to highlight specific dates with custom styles in jQuery UI Datepicker?
13 hours ago in Node-js by Nidhi
• 14,200 points
14 views

1 answer to this question.

0 votes

Here's how to highlight specific dates with custom styles in jQuery UI Datepicker:

Basic Solution

$(function() {

  $("#datepicker").datepicker({

    beforeShowDay: function(date) {

      // Define dates to highlight (format: [Y,M,D])

      var highlightDates = [

        [2023, 11, 25], // Christmas

        [2023, 0, 1],   // New Year's Day

        [2023, 6, 4]    // Independence Day (example)

      ];


      for (var i = 0; i < highlightDates.length; i++) {

        if (date.getFullYear() === highlightDates[i][0] && 

            date.getMonth() === highlightDates[i][1] && 

            date.getDate() === highlightDates[i][2]) {

          return [true, 'highlight-date', 'Special Day'];

        }

      }

      return [true, ''];

    }

  });

});

CSS Styling


.highlight-date a {

  background-color: #ff5252 !important;

  color: white !important;

  border-radius: 50%;

  font-weight: bold;

}


.event-date a {

  background-color: #2196F3 !important;

}

answered 7 hours ago by anonymous

Related Questions In Node-js

0 votes
0 answers

How to integrate jQuery UI Tabs with AJAX content loading?

Can you explain with the help of ...READ MORE

13 hours ago in Node-js by Ashutosh
• 25,410 points
12 views
0 votes
0 answers

How to create interactive tooltips with links using jQuery UI Tooltip?

Can you tell me how to create ...READ MORE

13 hours ago in Node-js by Ashutosh
• 25,410 points
11 views
0 votes
1 answer

How to implement grid layouts with nested columns in jQuery Mobile?

The most effective way to implement nested ...READ MORE

answered 7 hours ago in Node-js by anonymous
16 views
0 votes
1 answer

How to paginate with Mongoose in Node.js?

Hello @kartik, You can chain just like that: var ...READ MORE

answered Jul 15, 2020 in Node-js by Niroj
• 82,840 points
1,026 views
0 votes
0 answers

How to create a single-page navigation system using jQuery Mobile?

Can you tell me How to create ...READ MORE

13 hours ago in Node-js by Nidhi
• 14,200 points
12 views
0 votes
0 answers

How to implement a time picker alongside jQuery UI Datepicker?

Can you explian to me How to ...READ MORE

13 hours ago in Node-js by Nidhi
• 14,200 points
12 views
0 votes
1 answer

How to style individual menu items differently in jQuery UI Menu?

To style individual menu items differently in ...READ MORE

answered 7 hours ago in Node-js by anonymous
13 views
0 votes
1 answer

How to implement swipe gestures for navigation in jQuery Mobile?

To enable swipe gestures for page navigation ...READ MORE

answered 7 hours ago in Node-js by anonymous
16 views
0 votes
1 answer

How to disable weekends in jQuery UI Datepicker selection?

To disable weekends (Saturdays and Sundays) in ...READ MORE

answered 7 hours ago in Node-js by anonymous
15 views
0 votes
1 answer

How to position jQuery UI Tooltip relative to a specific element on the page?

To position a jQuery UI Tooltip relative ...READ MORE

answered 7 hours ago in Node-js by anonymous
9 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP