Latest web development tutorials

HTML DOM Input Range 對象

Input Range 對象

Input Range 對像是HTML5 新增的。

Input Range 對象表示使用type="range" 屬性的HTML <input> 元素。

注意: Internet Explorer 9及更早IE版本不支持使用type="range"屬性的HTML <input>元素。 .

訪問Input Range 對象

你可以使用getElementById() 函數來訪問使用type="range" 屬性的<input> 元素:

var x = document.getElementById("myRange"); 嘗試一下

提示:你同樣可以通過表單的元素集合來訪問Input Range對象。

創建Input Range 對象

你可以使用document.createElement() 方法來創建使用type="range" 屬性的<input> 元素:

var x = document.createElement("INPUT");
x.setAttribute("type", "range"); 嘗試一下

Input Range 對象屬性

屬性 描述
autocomplete 設置或返回滑塊控件的autocomplete 屬性值
autofocus 設置或返回滑塊控件在頁面加載後是否自動獲取焦點
defaultValue 設置或返回滑塊控件默認的值
disabled 設置或返回滑塊控件是否可用
form 返回使用滑塊控件的表單引用
list 返回包含了滑塊控件的datalist 引用
max 設置或返回滑塊控件的max 屬性值
min 設置或返回滑塊控件的min 屬性值
name 設置或返回滑塊控件的name 屬性值
step 設置或返回滑塊控件的step 屬性值
type 返回滑塊控件的表單類型
value 設置或返回滑塊控件的value 屬性值

標準屬性和事件

Input Range對象同樣支持標準屬性事件


相關文章

HTML教程: HTML表單

HTML參考手冊: HTML <input>標籤

HTML參考手冊: HTML <input> type屬性