Checkbox formプロパティ

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

定義と使い方

form プロパティは、チェックボックスを含むフォームへの参照を返します。

このプロパティは form オブジェクトを返します。

構文

checkboxObject.form


ブラウザサポート

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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


例

例

以下の例では、この checkbox が属するフォームの id を返します:

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

<form id="form1">
<input type="checkbox" id="myCheck">夏は好きですか?
</form>
<button type="button" onclick="displayResult()">チェックボックスを含むフォームIDを表示</button>

</body>
</html>

試してみる »


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