The HTMLOutputElement
interface provides properties and methods (beyond those inherited from {{domxref("HTMLElement")}}) for manipulating the layout and presentation of {{HTMLElement("output")}} elements.
Properties
Inherits properties from its parent, {{domxref("HTMLElement")}}.
Name | Type | Description |
---|---|---|
defaultValue |
{{domxref("DOMString")}} | The default value of the element, initially the empty string. |
form {{readonlyInline}} |
{{domxref("HTMLFormElement")}} | Indicates the control's form owner, reflecting the {{htmlattrxref("form", "output")}} HTML attribute if it is defined. |
htmlFor {{readonlyInline}} |
{{domxref("DOMSettableTokenList")}} | Reflects the {{htmlattrxref("for", "output")}} HTML attribute, containing a list of IDs of other elements in the same document that contribute to (or otherwise affect) the calculated value . |
labels {{readonlyInline}} |
{{domxref("NodeList")}} | A list of label elements associated with this output element. |
name |
{{domxref("DOMString")}} | Reflects the {{htmlattrxref("name", "output")}} HTML attribute, containing the name for the control that is submitted with form data. |
type |
{{domxref("DOMString")}} | Must be the string output . |
validationMessage |
{{domxref("DOMString")}} | A localized message that describes the validation constraints that the control does not satisfy (if any). This is the empty string if the control is not a candidate for constraint validation (willValidate is false ), or it satisfies its constraints. |
validity {{readonlyInline}} |
{{domxref("ValidityState")}} | The validity states that this element is in. |
value |
{{domxref("DOMString")}} | The value of the contents of the elements. Behaves like the {{domxref("Node.textContent")}} property. |
willValidate {{readonlyInline}} |
{{domxref("Boolean")}} | The behavior of this property is subject to an open specification bug, as some browser maker are not happy with what is specified. It is unclear which will be the final the outcome of this. The standard behavior is to always return false because output objects are never candidates for constraint validation.The proposed new behavior, implemented in Firefox since Gecko 2.0 is to use this property to indicate whether the element is a candidate for constraint validation. It is false if any conditions bar it from constraint validation (See {{Bug("604673")}}). |
Methods
Inherits methods from its parent, {{domxref("HTMLElement")}}.
Name & Arguments | Return | Description |
---|---|---|
checkValidity() |
{{domxref("Boolean")}} | The behavior of this property is subject to an open specification bug, as some browser maker are not happy with what is specified. It is unclear which will be the final the outcome of this. The standard behavior is to always return true because output objects are never candidates for constraint validation.The proposed new behavior, implemented in Firefox since Gecko 2.0 is to return false if the element is a candidate for constraint validation, and it does not satisfy its constraints. In this case, it also fires an {{event("invalid")}} event at the element. It returns true if the element is not a candidate for constraint validation, or if it satisfies its constraints (See {{Bug("604673")}}.). |
setCustomValidity (in {{domxref("DOMString")}} error) |
void |
Sets a custom validity message for the element. If this message is not the empty string, then the element is suffering from a custom validity error, and does not validate. |
Modes
This element behaves in one of two modes: default mode and value mode.
Default Mode
Initially, the element is in default mode, and so the contents of the element represent both the value of the element and its default value.
If the element is in default mode when the descendants of the element are changed in any way, the defaultValue
property is set to the value of the {{domxref("Node.textContent","textContent")}} property.
Resetting the form puts the element into default mode, and sets the {{domxref("Node.textContent","textContent")}} property to the value of the defaultValue
property.
Value Mode
The element goes into value mode when the contents of the value
property are set. The value
property otherwise behaves like the {{domxref("Node.textContent","textContent")}} property. When the element is in value mode, the default value is accessible only through the defaultValue
property.
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('HTML WHATWG', "forms.html#the-output-element", "HTMLOutputElement")}} | {{Spec2('HTML WHATWG')}} | No change from {{SpecName("HTML5 W3C")}}. |
{{SpecName('HTML5.1', "forms.html#the-output-element", "HTMLOutputElement")}} | {{Spec2('HTML5.1')}} | |
{{SpecName('HTML5 W3C', "forms.html#the-output-element", "HTMLOutputElement")}} | {{Spec2('HTML5 W3C')}} | Initial definition. |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatGeckoDesktop(2.0)}} | {{ CompatNo() }} | {{CompatVersionUnknown}} | 5.1 |
labels |
{{CompatVersionUnknown}} | {{CompatNo}}{{bug(556743)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatGeckoMobile(2.0)}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatNo}} |
labels |
{{CompatVersionUnknown}} | {{CompatNo}}{{bug(556743)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatNo}} |
See also
- The HTML element implementing this interface: {{ HTMLElement("output") }}.