Checkbox typeプロパティ
Checkbox オブジェクト
定義と使い方
type プロパティは、要素のフォームタイプを返します。
checkbox オブジェクトの場合、このプロパティは常に "checkbox" を返します。
構文
checkboxObject.type
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザが type プロパティをサポートしています。
例
例
次の例では、checkbox のフォーム要素タイプを返します:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function displayResult(){
var x=document.getElementById("check1").type;
alert(x);
}
</script>
</head>
<body>
<form>
<input type="checkbox" id="check1">夏は好きですか?
</form>
<button type="button" onclick="displayResult()">input タイプを表示</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function displayResult(){
var x=document.getElementById("check1").type;
alert(x);
}
</script>
</head>
<body>
<form>
<input type="checkbox" id="check1">夏は好きですか?
</form>
<button type="button" onclick="displayResult()">input タイプを表示</button>
</body>
</html>
試してみる »
Checkbox オブジェクト その他の拡張