วัตถุวิทยุอินพุต HTML DOM
วัตถุวิทยุอินพุต
ออบเจกต์ Input Radio แสดงถึงองค์ประกอบ <input> HTML ที่มี type="radio"
เข้าถึงวัตถุวิทยุอินพุต
คุณสามารถเข้าถึง <input> องค์ประกอบด้วย type="radio" โดยใช้ getElementById():
ตัวอย่าง
var x = document.getElementById("myRadio");
เคล็ดลับ:คุณยังสามารถเข้าถึง <input type="radio"> โดยการค้นหาผ่านคอลเล็กชันองค์ประกอบ ของแบบฟอร์ม
สร้างวัตถุวิทยุอินพุต
คุณสามารถสร้าง <input> องค์ประกอบด้วย type="radio" โดยใช้ document.createElement() วิธีการ:
ตัวอย่าง
var x = document.createElement("INPUT");
x.setAttribute("type", "radio");
อินพุตคุณสมบัติของวัตถุวิทยุ
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 |
คุณสมบัติและเหตุการณ์มาตรฐาน
ออบเจ็กต์ Input Radio ยังสนับสนุนคุณสมบัติและเหตุการณ์ มาตรฐาน อีกด้วย
หน้าที่เกี่ยวข้อง
กวดวิชา HTML: แบบฟอร์ม HTML
อ้างอิง HTML: HTML <input> tag
อ้างอิง HTML: HTML <input> ประเภทแอตทริบิวต์