The HTMLOutputElement
interface provides properties and methods (beyond those inherited from HTMLElement
) for manipulating the layout and presentation of <output>
elements.
Inherits properties from its parent, HTMLElement
.
Name | Type | Description |
---|---|---|
defaultValue | DOMString | The default value of the element, initially the empty string. |
form Read only
| HTMLFormElement | Indicates the control's form owner, reflecting the form HTML attribute if it is defined. |
htmlFor Read only
| DOMSettableTokenList | Reflects the for HTML attribute, containing a list of IDs of other elements in the same document that contribute to (or otherwise affect) the calculated value . |
labels Read only
| NodeList | A list of label elements associated with this output element. |
name | DOMString | Reflects the name HTML attribute, containing the name for the control that is submitted with form data. |
type | DOMString | Must be the string output . |
validationMessage | 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 Read only
| ValidityState | The validity states that this element is in. |
value | DOMString | The value of the contents of the elements. Behaves like the Node.textContent property. |
willValidate Read only
| 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). |
Inherits methods from its parent, HTMLElement
.
Name & Arguments | Return | Description |
---|---|---|
checkValidity() | 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 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 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. |
This element behaves in one of two modes: default mode and value 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 textContent
property.
Resetting the form puts the element into default mode, and sets the textContent
property to the value of the defaultValue
property.
The element goes into value mode when the contents of the value
property are set. The value
property otherwise behaves like the textContent
property. When the element is in value mode, the default value is accessible only through the defaultValue
property.
Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard The definition of 'HTMLOutputElement' in that specification. | Living Standard | No change from HTML5. |
HTML5.1 The definition of 'HTMLOutputElement' in that specification. | Recommendation | |
HTML5 The definition of 'HTMLOutputElement' in that specification. | Recommendation | Initial definition. |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | 4.0 (2.0) | No support | (Yes) | 5.1 |
labels | (Yes) | No support | No supportbug 556743 | ? | ? | ? |
Feature | Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | 4.0 (2.0) | (Yes) | (Yes) | No support |
labels | (Yes) | No support | No supportbug 556743 | ? | ? | No support |
<output>
.
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement