Radio typeプロパティ

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

定義と使い方

type プロパティは、ラジオボタンのフォーム要素タイプを返します。

ラジオボタンの場合、このプロパティは常に "radio" です。

構文

radioObject.type


ブラウザサポート

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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


例

例

次の例では、ラジオボタンのフォーム要素タイプを返します:

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

<form>
あなたはどの色が好きですか?<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()">input タイプを表示</button>

</body>
</html>

試してみる »


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