2016-03-08 211 views
0

我发现datetimepicker默认z-index1,但对我的网站我需要z-index9999。我已经改变了点击处理程序中的jquery的值,但它只能在第一次点击时起作用。连续点击不起作用。为什么是这样?如何在每次点击时更改datetimepicker的z-index?

<td style="height: 40px;"> 
    <input type="text" class="datetimepicker" name="sdate" placeholder="Start Date" style="height: 39px; width: 260px;">    
</td> 
<td style="height: 40px;"> 
    <input type="text" class="datetimepicker" name="edate" placeholder="End Date" style="height: 39px; width: 260px;">    
</td> 
$(document).ready(function() { 
    $('.datetimepicker').on('click', function(e) { 
     e.preventDefault(); 
     $(this).datetimepicker({ 
      dateFormat: "yy-mm-dd", 
      showTimezone: false, 
      maskInput: true, 
      timeFormat: "HH:mm:ss" 
     }).focus(); 
     $('#ui-datepicker-div').css("z-index", 9999); //this is once time work 
    }); 
}); 
+0

在CSS中设置'z-index'值 –

+0

是否尝试在css中设置'z-index',如果不起作用,则意味着每次打开'datetimepicker'时,它都会被重置它的'z-index'设置为'1',尝试调查更多 –

回答

1

我从http://xdsoft.net/找到了一些固定的代码,我刚加了destroy函数就行了。

$(document).ready(function() { 
$('.datetimepicker').on('click', function(e) { 
    e.preventDefault(); 
    $(this).datetimepicker({ 
     dateFormat: "yy-mm-dd", 
     showTimezone: false, 
     maskInput: true, 
     timeFormat: "HH:mm:ss" 
    }).focus(); 
    $('#ui-datepicker-div').css("z-index", 9999); //this is once time work 
    $(this).datetimepicker("destroy");//this is solved my problem 
}); 

});

+0

这可以用css来解决,正如Huseyin TUNC(http://stackoverflow.com/a/35863483/299708)所建议的那样。无需每次点击都销毁并重新初始化小部件。 – kennasoft

1

在你的CSS文件试试这个;

#ui-datepicker-div { 
    z-index: 99999 !important; 
}