gpt4 book ai didi

javascript - 在 jquery 中使用日期选择器,显示今天

转载 作者:行者123 更新时间:2023-12-02 18:30:44 25 4
gpt4 key购买 nike

我希望日期选择器选择当前日期/今天并显示它而不是“dd----yyyy”,而且我希望从选择中禁用今天之前的日期,请帮忙!

    $(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
});
});
});

这是我的 fiddle 的链接:

http://jsfiddle.net/L4reds/73pEN/1/

最佳答案

$(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());
});
});

FIDDLE

关于javascript - 在 jquery 中使用日期选择器,显示今天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17827411/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com