我希望datepicker选择currentdate / today并显示它而不是'dyyy'而且我希望今天之前的日期禁用选择,请帮忙!
$(document).ready(function () {
$("#button_id").click(function () {
$('<div/>', {
id: "div_id"
}).append($('<input>', {
type: "date",
name: "someDate",
class: "date_id"
})).appendTo("#static_div");
$(".date_id").datepicker({
//i want the datepicker to select the currentdate/today and display it instead of'dd----yyyy'and moreover i wanted the date before today to be disabled from selection
});
});
});
这是我小提琴的链接:
答案 0 :(得分:2)
$(document).ready(function () {
$("#button_id").click(function () {
var div = $('<div/>', {id: "div_id"}),
inp = $('<input>', {type: "text",name: "someDate",id: "date_id"});
div.append(inp).appendTo("#static_div");
inp.datepicker({
minDate: 0
}).datepicker('setDate', new Date());
});
});
答案 1 :(得分:0)
使用 minDate 和 maxDate 选项隐藏上一个日期see this
$(function() {
$( "#datepicker" ).datepicker({ minDate: -20, maxDate: "+1M +10D" });
});
答案 2 :(得分:0)
要在当天之前停用日期:
$("#date_id").datepicker({
minDate: 0
});