关于jquery中datepicker的z-index设置

我们使用jquery的datepicker时会发现一个问题,在生成的html代码中你会发现div的z-index属性为1

<div id="ui-datepicker-div" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" style="position: absolute; top: 236px; left: 372px; z-index: 1; display: block;">

如何把这个z-index的指设置为我们想要的指呢,我首先想到了jquery.ui.datepicker.js,然后去里面找,在第746行发现jquery设置datepicker的z-index的地方

    if (!inst.inline) {
            showAnim = $.datepicker._get(inst, "showAnim");
            duration = $.datepicker._get(inst, "duration");
            inst.dpDiv.zIndex($(input).zIndex()+1);//就是这里设置的
            $.datepicker._datepickerShowing = true;

于是改了一下,发现不行,去网上找了一些资料,终于发现问题所在了,要修改它需要在jquery ui.js中进行修改,我们打开jquery ui.js找到定义datepicker的地方,在3919行

    inst.dpDiv.zIndex($(input).zIndex()+15);//这里最初是+1,我把它改成了+15
            $.datepicker._datepickerShowing = true;

我们把它的值改动一下就行。我使用的是jquery-ui-1.9.2.custom.js这个版本

 

posted @ 2014-03-31 19:45  生有涯而知无涯  阅读(1475)  评论(0)    收藏  举报