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