HTML DOM Input Radio Obheto

Input Radio 對象

Input Radio 對象代表帶有 type="radio" 的 HTML <input> 元素。

訪問 Input Radio 對象

您可以使用 getElementById() 访問 type="radio" 的 <input> 元素:

var x = document.getElementById("myRadio");

親自試內試

提示:您還可以通過搜索表單的 elements 集合 來訪問 <input type="radio">。

創建 Input Radio 對象

您可以使用 document.createElement() 方法創建 type="radio" 的 <input> 元素:

var x = document.createElement("INPUT");
x.setAttribute("type", "radio");

親自試內試

Input Radio 對象屬性

属性 描述
autofocus 設置或返回單選按鈕是否應在頁面加載時自動獲得焦點。
checked 設置或返回單選按鈕的選中狀態。
defaultChecked 返回 checked 屬性的默認值。
defaultValue 設置或返回單選按鈕的默認值。
disabled 設置或返回是否禁用單選按鈕。
form 返回對包含單選按鈕的表單的引用。
name 設置或返回單選按鈕 name 屬性值。
required 設置或返回在提交表單之前是否必須選中單選按鈕。
type 返回單選按鈕是哪種類型的表單元素。
value 設置或返回單選按鈕的 value 屬性值。

標內准屬性和事件

Input Radio 對象同時支持標內准属性事件

相关內页面

HTML 教內程:HTML 表单

HTML 参內考手內册:HTML <input> 标签

HTML 参內考手內册:HTML <input> type 属性