Đối tượng vô tuyến đầu vào HTML DOM
Đối tượng vô tuyến đầu vào
Đối tượng Radio đầu vào đại diện cho một phần tử HTML <input> với type = "radio".
Truy cập một đối tượng vô tuyến đầu vào
Bạn có thể truy cập phần tử <input> với type = "radio" bằng cách sử dụng getElementById ():
Thí dụ
var x = document.getElementById("myRadio");
Mẹo: Bạn cũng có thể truy cập <input type = "radio"> bằng cách tìm kiếm trong bộ sưu tập phần tử của một biểu mẫu.
Tạo một đối tượng vô tuyến đầu vào
Bạn có thể tạo phần tử <input> với type = "radio" bằng cách sử dụng phương thức document.createElement ():
Thí dụ
var x = document.createElement("INPUT");
x.setAttribute("type", "radio");
Thuộc tính đối tượng vô tuyến đầu vào
Property | Description |
---|---|
autofocus | Sets or returns whether a radio button should automatically get focus when the page loads |
checked | Sets or returns the checked state of a radio button |
defaultChecked | Returns the default value of the checked attribute |
defaultValue | Sets or returns the default value of a radio button |
disabled | Sets or returns whether the radio button is disabled, or not |
form | Returns a reference to the form that contains the radio button |
name | Sets or returns the value of the name attribute of a radio button |
required | Sets or returns whether the radio button must be checked before submitting a form |
type | Returns which type of form element the radio button is |
value | Sets or returns the value of the value attribute of the radio button |
Thuộc tính và sự kiện tiêu chuẩn
Đối tượng Input Radio 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>