我遇到了由別人實現的日期選擇器的問題。我試圖在我的網站上實現代碼,但它不起作用。以下是JavaScript DatePickerJquery DatePicker出現在其他常規頁面元素的後面
// init datepicker
function initDatepicker(){
jQuery('.with-datepicker').each(function(){
var hold = jQuery(this);
var input = hold.find('input:text');
var opener = hold.find('.btn');
input.datepicker({
showOtherMonths: true
})
opener.bind('click', function(e){
input.focus();
e.preventDefault();
})
})
}
所以我的問題是2倍。
A)我不明白什麼input.focus()實際上是做除了調用重點jQuery(this).find('input:text').focus();
乙)日期選擇器「當我嘗試點擊日期選擇器時,它會消失並且不會選擇日期。
更多的信息給你是我用這個聯繫表格7有一個文本框,你可以點擊激活日期選擇器。這部分似乎工作正常。日期選擇器直接顯示在顯示「選擇日期」的輸入框下方。問題是datepicker類是其他元素(如單選按鈕)的後面。
我也試過之後input.focus();
$(this).parent().css('position', 'relative');
$(this).parent().css('z-index', 3000);
下面這樣做是一個鏈接到它的外觀在頁面上:
你選擇塊是什麼意思? – camdixon
我的意思是標籤,你必須單擊,以顯示DatePicker。在這裏,例如'Event Date 1st Choice'按鈕。 **每個**對這樣的按鈕和Datepicker應該有**一個父**。 **或者**您可以在「button」塊內放置Datepicker('position:absolute;'),並使用'position:relative;'來解決您的問題。 –