2016-03-08 209 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; 
}