2013-10-02 28 views
0

我目前有這個腳本,它給了我一個圖像旁邊的文本框。如果我點擊圖片,它顯示了日期選擇器:使文本框和圖像調出日期選擇器

$("#txtDate").datepicker({ 
    changeMonth: true, 
    changeYear: true, 
    yearRange: "+0:+1", 
    showButtonPanel: false, 
    dateFormat: "dd/mm/yy", 
    showOn: "button", 
    buttonImage: "image.png", 
    buttonImageOnly: true, 
    onClose: function() { 

     selectedDateTime($("#txtDate").val(), $("#ddlHourTime").val(), $("#ddlMinuteTime").val()); 

    } 
}); 

如何改變此日期選取器顯示本身如果單擊文本框或圖像。目前,當我點擊文本框時沒有任何反應。

回答

2

你的問題是你如何設置showOn。它被設置爲「按鈕」,所以它只會在點擊時打開日期選擇器。將其更改爲「Both」,並且它會在兩個文本框中單擊abe按鈕單擊打開。

這裏是一個jsfiddle

$("#txtDateBoth").datepicker({ 
    changeMonth: true, 
    changeYear: true, 
    yearRange: "+0:+1", 
    showButtonPanel: false, 
    dateFormat: "dd/mm/yy", 
    showOn: "both", 
    buttonImage: "image.png", 
    buttonImageOnly: true, 
}); 
+0

+1爲正確答案。 –

相關問題