Jquery date picker z-index issue

JqueryJquery PluginsUidatepicker

Jquery Problem Overview


I have a slideshow div, and I have a datepicker field above that div.

When I click in the datepicker field, the datepicker panel show behind slideshow div.

And I have put the script as:

http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js

So I cannot change the z-index of datepicker in CSS. The z-index of datepicker which the script is generating is 1 and my slideshow div(also calling thru googleajaxapi) z-index is 5. So I guess I have to increase the z-index of date picker greater than 5. So is there any way to increase it ?

Someone can help me?

Jquery Solutions


Solution 1 - Jquery

Put the following style at the 'input' text element: position: relative; z-index: 100000;.

The datepicker div takes the z-index from the input, but this works only if the position is relative.

Using this way you don't have to modify any javascript from jQuery UI.

Solution 2 - Jquery

simply in your css use '.ui-datepicker{ z-index: 9999 !important;}' Here 9999 can be replaced to whatever layer value you want your datepicker available. Neither any code is to be commented nor adding 'position:relative;' css on input elements. Because increasing the z-index of input elements will have effect on all input type buttons, which may not be needed for some cases.

Solution 3 - Jquery

worked for me

.hasDatepicker {
	position: relative;
	z-index: 9999;
}

Solution 4 - Jquery

Based in marksyzm answer, this worked for me:

$('input').datepicker({
    beforeShow:function(input) {
        $(input).css({
            "position": "relative",
            "z-index": 999999
        });
    }
});

Solution 5 - Jquery

I have a dialog box that uses the datepicker on it. It was always hidden. When I adjusted the z-index, the field on the lower form always showed up on the dialog.

I used a combination of solutions that I saw to resolve the issue.

$('.ui-datepicker', $form).datepicker({
                showButtonPanel: true,
                changeMonth: true,
                changeYear: true,
                dateFormat: "yy-M-dd",
                beforeShow: function (input) {
                    $(input).css({
                        "position": "relative",
                        "z-index": 999999
                    });
                },
                onClose: function () { $('.ui-datepicker').css({ 'z-index': 0  } ); }                    
            });

The before show ensures that datepicker always is on top when selected, but the onClose ensures that the z-index of the field gets reset so that it doesn't overlap on any dialogs opened later with a different datepicker.

Solution 6 - Jquery

Adding to Justin's answer, if you're worried about untidy markup or you don't want this value hard coded in CSS you can set the input before it is shown. Something like this:

$('input').datepicker({
    beforeShow:function(input){
        $(input).dialog("widget").css({
            "position": "relative",
            "z-index": 20
        });
    }
});

Note that you cannot omit the "position": "relative" rule, as the plugin either looks in the inline style for both rules or the stylesheet, but not both.

The dialog("widget") is the actual datepicker that pops up.

Solution 7 - Jquery

I had this issue i solved by using on click:

var checkin = $('.dpd1').datepicker()
.on('click', function (ev) {
        $('.datepicker').css("z-index", "999999999");
}).data('datepicker');

Solution 8 - Jquery

Solution 9 - Jquery

I have a page where the datepicker was on top of a datatables.net tabletools button. The datatables buttons had a higher z-index than the individual datepicker date buttons. Thanks to Ronye's answer I was able to resolve this problem by using position: relative; and z-index: 10000. Thanks!

Solution 10 - Jquery

This happened to me when I was missing the theme. Make sure the theme exists, or perhaps redownoad the theme, and reupload it to your server.

Solution 11 - Jquery

That what solved my problem:

 $( document ).ready(function() {   
    $('#datepickerid').datepicker({
     zIndexOffset: 1040 #or any number you want
     });
});

Solution 12 - Jquery

In fact you can effectively add in your css .ui-datepicker{ z-index: 9999 !important;} but you can modify jquery-ui.css or jquery-ui.min.css and add at the end of the ui-datepicker class z-index: 9999 !important;. both things work for me (You only need one ;-))

Solution 13 - Jquery

I had to

.datepicker.dropdown-menu {
    position: relative;
    z-index: 9999 !important;
}

Solution 14 - Jquery

I had this issue as well, since the datepicker uses the input's z-index, I added the following css

#dialogID input,.modal-dialog input, .modal-dialog .input-group .form-control{
  z-index:inherit;
}

Just take the rule that applies to yours, either by parent id, class, or in my case a bootstrap dialog, using their input-group and form-control.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionrubyistView Question on Stackoverflow
Solution 1 - JqueryRonye VernaesView Answer on Stackoverflow
Solution 2 - JqueryAakash SahaiView Answer on Stackoverflow
Solution 3 - JqueryBashmakov EvgeniyView Answer on Stackoverflow
Solution 4 - JqueryLucasView Answer on Stackoverflow
Solution 5 - JqueryHarry BinnendykView Answer on Stackoverflow
Solution 6 - JquerymarksyzmView Answer on Stackoverflow
Solution 7 - JqueryWaqlehView Answer on Stackoverflow
Solution 8 - JquerySlawaView Answer on Stackoverflow
Solution 9 - JqueryTMNetworksView Answer on Stackoverflow
Solution 10 - Jqueryuser725913View Answer on Stackoverflow
Solution 11 - JquerylimilouView Answer on Stackoverflow
Solution 12 - JqueryLeSage StarkView Answer on Stackoverflow
Solution 13 - JqueryiMitweView Answer on Stackoverflow
Solution 14 - JqueryJaynesifyView Answer on Stackoverflow