HTML DOM Input DatetimeLocal 对象

Input DatetimeLocal 对象

Input DatetimeLocal 对象是 HTML5 新增的。

Input DatetimeLocal 对象表示使用 type="datetime-local" 的 HTML <input> 元素。

注意:Internet Explorer 或 Firefox 浏览器不支持 <input> 元素。

访问 Input DatetimeLocal 对象

你可以使用 getElementById() 函数来访问使用 type="datetime-local" 属性的 <input> 元素:

var x = document.getElementById("myLocalDate"); 运行代码

提示: 你同样可以通过表单的元素集合来访问 Input DatetimeLocal 对象。

创建 Input DatetimeLocal 对象

你可以使用 document.createElement() 方法来创建使用 type="datetime-local" 属性的 <input> 元素:

var x = document.createElement("INPUT");
x.setAttribute("type", "datetime-local"); 运行代码

Input DatetimeLocal 对象属性

属性 描述
autocomplete 设置或返回本地时间字段的 autocomplete 属性值
autofocus 设置或返回本地时间字段在页面加载后是否自动获取焦点
defaultValue 设置或返回本地时间字段默认的值
disabled 设置或返回本地时间字段是否可用
form 返回使用本地时间字段的表单引用
list 返回包含了本地时间字段的 datalist 引用
max 设置或返回本地时间字段的 max 属性值
min 设置或返回本地时间字段的 min 属性值
name 设置或返回本地时间字段的 name 属性值
readOnly 设置或返回本地时间字段是否只读
required 设置或返回本地时间字段在表单中是否为必填字段
step 设置或返回本地时间字段的 step 属性值
type 返回本地时间字段的表单元素类型
value 设置或返回本地时间字段的 value 属性值

标准属性和事件

Input DatetimeLocal 对象同样支持标准 属性事件


相关文章

HTML 教程: HTML 表单

HTML 参考手册: HTML <input> 标签

HTML 参考手册: HTML <input> type 属性