Button formプロパティ

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

定義と用法

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

そのボタンが含まれている場合は form オブジェクトを返し、含まれていない場合は null を返します。

構文

buttonObject.form


ブラウザサポート

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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


例

例

次の例では、このボタンが属するフォームの id を返します。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>初心者向けチュートリアル(example.com)</title>
</head>
<body>

<form id="form1">
<button id="button1" type="button">クリック!</button>
</form>
<p>ボタンを含むフォームのID:
<script>
document.write(document.getElementById("button1").form.id);
</script></p>

</body>
</html>

試してみる »


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