Ways to style specific dates on a datepicker?

Is there a way to customize the appearance of the first and last selected days in my ui datepicker for booking, similar to the design shown in the image linked below?


            var dateFormat = "DD/MM/YY",
            from = $("#checkin,.checkin").datepicker({
              firstDay: 1,
              minDate: 0,
              showButtonPanel: true,
              closeText: 'Temizle',
              onClose: function(dateText, inst) {
                if ($(window.event.srcElement).hasClass('ui-datepicker-close')) {
                  document.getElementById(this.id).value = '';
                  //$('.checkin,#checkin,#checkout,.checkout').val('');
                }
              },
              onSelect: function(date) {
                window.setTimeout($.proxy(function() {
                  $(this).parents(".book-holiday").find("#checkout,.checkout").focus();
                }, this), 10);
                var date2 = $('#checkin,.checkin').datepicker('getDate');
                date2.setDate(date2.getDate() + 1);
                //$('#dt2').datepicker('setDate', date2);
                //sets minDate to dt1 date + 1
                $('#checkout,.checkout').datepicker('option', 'minDate', date2);
              },
              isTo1: true,
              beforeShow: function(input, inst) {
                $(this).datepicker("widget").addClass("main-datepicker");
              }
            });
          $("#checkout,.checkout").datepicker({
            firstDay: 1,
            minDate: 0,
            showButtonPanel: true,
            closeText: 'Temizle',
            onClose: function(dateText, inst) {
              if ($(window.event.srcElement).hasClass('ui-datepicker-close')) {
                document.getElementById(this.id).value = '';
                //$('.checkin,#checkin,#checkout,.checkout').val('');
              }
              var dt1 = $('#checkin,.checkin').datepicker('getDate');
              console.log(dt1);
              var dt2 = $('#checkout,.checkout').datepicker('getDate');
              if (dt2 <= dt1) {
                var minDate = $('#checkout,.checkout').datepicker('option', 'minDate');
                $('#checkout,.checkout').datepicker('setDate', minDate);
              }
            },
            isTo1: true,

            onSelect: function(selectedDate) {
              $(this).parents(".book-holiday").find(".popover-wrapper").addClass("open");
            },
            beforeShow: function(input, inst) {
              $(this).datepicker("widget").addClass("main-datepicker");
            }

          });
      
<link href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet" /> From : <input type="text" class="checkin"> To: <input type="text" class="checkout">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

Check out the Codepen Demo here

Answer №1

To customize the appearance of jquery-ui.css selector and change the colors displayed, you can modify it as shown below for the initial day.

.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight 
{
  background: #e96e5e;
}

Could you provide additional details on your requirements?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Challenge with the Bootstrap 3 grid structure involving nesting

On my .aspx page, I have the code snippet below: .cDiv { background-color: gray; } .tColor { background-color:yellow; } .tColor2 { background-color:blue; } <div class="container"> <div class="row"> <div class="col-sm-9 tColor" ...

Bring the URL back to its original state upon refreshing the page

A form was created using a combination of HTML and PHP on my website. This specific form takes a number as input, adds 2 to that number, and then displays the result. For instance, if the user enters the number 5 and clicks the submit button, the page wil ...

Jquery Triggers Failing to Work Following Ajax Request

I have worked on 2 PHP pages, called "booking.php" and "fetch_book_time.php". Within my booking.php (where the jquery trigger is) <?php include ("conn.php"); include ("functions.php"); ?> $(document).ready(function(){ $(".form-group"). ...

Seeking out all (including potentially relative) URLs on a webpage: Possible strategies to consider

For a coding challenge, I am working on a small python tool to download an entire website locally. In order to view the website offline, I need to convert all URLs to relative URLs. This is necessary to ensure that resource files (such as .js and .css) are ...

How to switch the code from using $.ajax() to employing $.getJSON in your script

How can I convert this code from using AJAX to JSON for better efficiency? AJAX $('#movie-list').on('click', '.see-detail', function() { $.ajax({ url: 'http://omdbapi.com', dataType: 'json', d ...

Encountering the error code 'ERR_EMPTY_RESPONSE' while utilizing an AJAX-powered live search feature

My website features a live AJAX search bar that retrieves records from a MySQL database. However, when users repeatedly conduct searches by modifying the search criteria, some web browsers display an error message stating 'ERR_EMPTY_RESPONSE'. ...

Ensure that HTML Tidy does not disrupt meta tags, specifically schema markup

Encountering a significant issue with the latest version of HTML Tidy - visit https://html-tidy.org. To summarize: HTML Tidy is altering these HTML code lines: <div class="breadcrumbs" typeof="BreadcrumbList" vocab="http://schema.org/"> <div cla ...

Tips on avoiding scrolling when toggling the mobile navigation bar:

While working on a website using HTML, CSS, and BS3, I have created a basic mobile navigation. However, I am facing an issue where I want to disable scrolling of the body when toggling the hamburger button. The problem arises when the menu is toggled on, ...

Use CSS specifically for codeigniter viewpage

I am unsure if it is possible, but I would like to load CSS and JavaScript within a view page instead of on include.php. Currently, the CSS file is loading on include.php and it is working correctly. What I want to achieve now is to load it directly inside ...

Ways to separate a portion of the information from an AJAX Success response

I am currently working on a PHP code snippet that retrieves data from a database as follows: <?php include './database_connect.php'; $ppid=$_POST['selectPatientID']; $query="SELECT * FROM patient WHERE p_Id='$ppid'"; $r ...

struggling to rectify an undefined index error on my PHP page

My challenge revolves around accessing the token from an HTML page, where I have an input element containing the token. Whenever I try running this page on a server (WAMP) on Windows 7, I encounter an error stating "undefined index" on the "api_key". How ...

Building a new directory in Laravel

I am facing an issue with allowing users to create a folder in Laravel 4 through an ajax request that goes through the route and controller@method. I have tested the ajax success request to ensure it calls the right method. However, when I try to use mkdir ...

Language translation API specifically designed to convert text content excluding any HTML formatting

I have a dilemma with translating text content in an HTML file into multiple languages based on user input. To accomplish this, I am utilizing the Microsoft Translator AJAX interface. The structure of my HTML file looks something like this; <h1>< ...

a table in HTML with cells positioned in the center

My requirement is for a table with one row and 5 cells. The first/left cell should be left justified, the last/right cell should be right justified, and the middle 3 cells should be centered with equal spacing between them. The table itself has a "100% wid ...

Adjusting the appearance of a JavaScript element based on its hierarchy level

Currently, I am utilizing Jqtree to create a drag and drop tree structure. My main goal is to customize the appearance of the tree based on different node levels. Javascript Tree Structure var data = [ { name: 'node1', id: 1, chi ...

Utilize the 'document / redirect' API within an express controller function

Here is how I have an API call using document / redirect: This call is made within HTML Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmln ...

Uploading multiple images using Cordova's File Transfer feature

Working on a project using Cordova and jQuery Mobile, my goal is to upload multiple images with the file transfer plugin. After successfully uploading one image, I am now attempting to upload 2 or 3 images in succession. Below is the HTML code snippet: ...

Attempting to showcase a pair of unordered lists side by side using the power of flexbox

I am having trouble getting this to display on a single line, no matter what I try. While there may be simpler ways to achieve this without using flexbox, I am eager to learn how to do it using flexbox properties. My desired outcome is to have the first u ...

What is the best method for eliminating underscores from text that is hyperlinked in a locally hosted HTML file?

I recently encountered an issue with my HTML file where the text "Indian" became underlined after saving the file. Here is the code snippet: <a href="file:///G:\work files\project\indian.html" target="_blank"> <div class="button ...

Accessing variables from outside the query block in Node.js with SQLite

I'm looking to retrieve all the rows from a table and store them in an array called "arr". I need to access this stored array outside of the query section. Is there a way for me to get all the rows outside of the db.each function so that I can continu ...