Radio formプロパティ

Radio 对象参考手册Radio オブジェクト

定義と使用法

form プロパティは、そのボタンを含むフォームへの参照を返します。

成功した場合、このプロパティはフォームオブジェクトを返します。

構文

radioObject.form


ブラウザサポート

Internet ExplorerFirefoxOperaGoogle ChromeSafari

すべての主要ブラウザが form プロパティをサポートしています。


例

例

次の例は、このラジオボタンが属するフォームの id を返します:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function displayResult(){
    var x=document.getElementById("red").form.id;
    alert(x);
}
</script>
</head>
<body>

<form id="form1">
どの色が好きですか?<br>
<input type="radio" name="colors" id="red">赤<br>
<input type="radio" name="colors" id="blue">青<br>
<input type="radio" name="colors" id="green">緑
</form>
<button type="button" onclick="displayResult()">所属フォームのIDを表示</button>

</body>
</html>

試してみる »


Radio 对象参考手册Radio オブジェクト その他の拡張