DOM Interfaces

HTMLFormElement

Build a form with the HTML form generator

Represents a form, its associated controls and submission and reset operations. Controls can be associated from outside the form. Named controls can shadow built-in members such as submit and reset. Example result: 1.

Formal Syntax & Structure

html syntaxhtml
const element = document.getElementById('demo'); // HTMLFormElement

Return Value

HTMLFormElement

An existing HTML DOM object associated with the form element in this example; this interface is a type, not a function return contract.

Working Example

Example Snippethtml
<form id="demo">  <label>    Name    <input name="name">  </label></form><p>  Result:  <output id="result"></output></p><script>  const e = document.getElementById('demo');  const result = value => { document.getElementById("result").textContent = String(value); };  result(e.elements.length);</script>
HTML Reference