Latest web development tutorials

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屬性