Đối tượng phạm vi đầu vào HTML DOM
Đối tượng phạm vi đầu vào
Đối tượng Phạm vi đầu vào đại diện cho một phần tử HTML <input> với kiểu = "phạm vi".
Truy cập một đối tượng phạm vi đầu vào
Bạn có thể truy cập phần tử <input> với type = "range" bằng cách sử dụng getElementById ():
Thí dụ
var x = document.getElementById("myRange");
Mẹo: Bạn cũng có thể truy cập <input type = "range"> bằng cách tìm kiếm thông qua bộ sưu tập phần tử của một biểu mẫu.
Tạo một đối tượng phạm vi đầu vào
Bạn có thể tạo phần tử <input> với type = "range" bằng cách sử dụng phương thức document.createElement ():
Thí dụ
var x = document.createElement("INPUT");
x.setAttribute("type", "range");
Thuộc tính đối tượng phạm vi đầu vào
Property | Description |
---|---|
autocomplete | Sets or returns the value of the autocomplete attribute of a slider control |
autofocus | Sets or returns whether a slider control should automatically get focus when the page loads |
defaultValue | Sets or returns the default value of a slider control |
disabled | Sets or returns whether a slider control is disabled, or not |
form | Returns a reference to the form that contains the slider control |
list | Returns a reference to the datalist that contains the slider control |
max | Sets or returns the value of the max attribute of the slider control |
min | Sets or returns the value of the min attribute of the slider control |
name | Sets or returns the value of the name attribute of a slider control |
step | Sets or returns the value of the step attribute of the slider control |
type | Returns which type of form element the slider control is |
value | Sets or returns the value of the value attribute of a slider control |
Phương thức đối tượng phạm vi đầu vào
Method | Description |
---|---|
stepDown() | Decrements the value of the slider control by a specified number |
stepUp() | Increments the value of the slider control by a specified number |
Thuộc tính và sự kiện tiêu chuẩn
Đối tượng Phạm vi đầu vào cũng hỗ trợ các thuộc tính và sự kiện tiêu chuẩn .
Các trang liên quan
Hướng dẫn HTML: Biểu mẫu HTML
Tham chiếu HTML: Thẻ HTML <input>
Tham chiếu HTML: Thuộc tính loại HTML <input>