1
我想在同一頁面上使用多個日期輸入,其中一些必須使用格式yy-mm-dd
和其他格式yy-mm
。當我爲yy-mm
格式添加jQuery代碼格式輸入與yy-mm-dd
格式丟失日期,只有幾個月和幾年是可見的?如何在jquery中使用不同的日期格式輸入日期
$(function() {
var currentDate = new Date();
$(".datepicker").datepicker({ dateFormat: "yy-mm-dd" });
$(".datepicker").datepicker("setDate",currentDate);
});
$(function() {
$('.month-picker').datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'yy-mm',
onClose: function(dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
}
});
});
你是對的。問題是CSS'.ui-datepicker-calendar {display:none;}'。這個CSS只能應用於特定的HTML輸入嗎?我想只顯示monthpicker的月份和年份。 – Galuk