DOM

Document.forms プロパティ

 編集:2022.08.31 by T.A.

[Edge]読取専用。→

Document 内のすべての <form> 要素を列挙した HTMLCollection を返します。

メモ: 同様に、HTMLFormElement.elements プロパティを使用すると、フォーム コンポーネントのユーザー入力要素のリストにアクセスすることができます。

構文
Document.forms
Document Document

HTMLCollection

文書にフォームがない場合、返されるコレクションは空で、長さはゼロです。

フォーム情報の取得:

HTML:

<!DOCTYPE html>
<html lang="en">

<head>
<title>document.forms example</title>
</head>

<body>

<form id="robby">
  <input type="button" onclick="alert(document.forms[0].id);" value="robby's form" />
</form>

<form id="dave">
  <input type="button" onclick="alert(document.forms[1].id);" value="dave's form" />
</form>

<form id="paul">
  <input type="button" onclick="alert(document.forms[2].id);" value="paul's form" />
</form>

</body>
</html>

¶省く


テスト