输入日期值属性用于设置或返回日期字段的值属性的值。
输入日期值属性可用于为日期字段指定日期。
用法:
要返回value属性:inputdateObject.value
设置value属性:inputdateObject.value = YYYY-MM-DD
属性值:
YYYY-MM-DD:用于指定日期。YYYY:指定年份。
MM:指定月份。
DD:指定月份中的某天。
以下示例程序旨在说明Date值属性:
为日期时间字段设置日期。
Input Date value Property in HTMLh1 {
color:green;
}
h2 {
font-family:Impact;
}
body {
text-align:center;
}
GeeksforGeeks
Input Date value Property
Date Of Birth:
To set a date for the date field,
double-click the "Set Date" button.
Set Date
function My_Date() {
document.getElementById("Test_Date").value = "2019-02-04";
}
输出:
单击按钮后
支持的Web浏览器:
苹果Safari
IE浏览器
Firefox
谷歌浏览器
Opera