Đố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 phần tử HTML <input> có loại = "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():
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 thành phần của 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():
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.
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>