HTMLOutputElement

HTMLOutputElement interface provides properties and methods (beyond those inherited from HTMLElement ) for manipulating the layout and presentation of <output> elements.

特性

This interface also inherits properties from its parent, HTMLElement .

HTMLOutputElement.defaultValue
A DOMString representing the default value of the element, initially the empty string.
HTMLOutputElement.form 只读
An HTMLFormElement indicating the form associated with the control, reflecting the form HTML attribute if it is defined.
HTMLOutputElement.htmlFor 只读
A DOMTokenList reflecting 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 .
HTMLOutputElement.labels 只读
A NodeList of <label> elements associated with the element.
HTMLOutputElement.name
A DOMString reflecting the name HTML attribute, containing the name for the control that is submitted with form data.
HTMLOutputElement.type 只读
DOMString " output ".
HTMLOutputElement.validationMessage 只读
A DOMString representing 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.
HTMLOutputElement.validity 只读
A ValidityState representing the validity states that this element is in.
HTMLOutputElement.value
A DOMString representing the value of the contents of the elements. Behaves like the Node.textContent 特性。
HTMLOutputElement.willValidate 只读
A Boolean indicating whether the element is a candidate for constraint validation.

方法

This interface also inherits methods from its parent, HTMLElement .

HTMLOutputElement.checkValidity()
Checks the validity of the element and returns a Boolean holding the check result.
HTMLOutputElement.reportValidity()
This method reports the problems with the constraints on the element, if any, to the user. If there are problems, fires an invalid event at the element, and returns false ; if there are no problems, it returns true .
When the problem is reported, the user agent may focus the element and change the scrolling position of the document or perform some other action that brings the element to the user's attention. User agents may report more than one constraint violation if this element suffers from multiple problems at once. If the element is not rendered, then the user agent may report the error for the running script instead of notifying the user.
HTMLOutputElement.setCustomValidity()
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 模式。

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 textContent 特性。

Resetting the form puts the element into default mode, and sets the textContent property to the value of the defaultValue 特性。

Value mode

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 特性。

规范

规范 状态 Comment
HTML Living Standard
The definition of 'HTMLOutputElement' in that specification.
实时标准
HTML 5.1
The definition of 'HTMLOutputElement' in that specification.
Recommendation No change
HTML5
The definition of 'HTMLOutputElement' in that specification.
Recommendation 初始定义

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
HTMLOutputElement Chrome Yes Edge ≤18 Firefox 4 IE No Opera Yes Safari 5 WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS No Samsung Internet Android Yes
checkValidity Chrome Yes Edge 14 Firefox 4 IE No Opera Yes Safari 5 WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS No Samsung Internet Android Yes
defaultValue Chrome Yes Edge 14 Firefox 4 IE No Opera Yes Safari 5 WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS No Samsung Internet Android Yes
form Chrome Yes Edge 14 Firefox 4 IE No Opera Yes Safari 5 WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS No Samsung Internet Android Yes
htmlFor Chrome Yes
Yes
Before Chrome 50, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList .
Edge 14 Firefox 4 IE No Opera Yes
Yes
Before Opera 37, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList .
Safari 5 WebView Android Yes
Yes
Before Chrome 50, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList .
Chrome Android Yes
Yes
Before Chrome 50, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList .
Firefox Android 4 Opera Android Yes
Yes
Before Opera 37, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList .
Safari iOS No Samsung Internet Android Yes
Yes
Before Samsung Internet 5.0, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList .
labels Chrome Yes Edge 18 Firefox 56 IE No Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 56 Opera Android ? Safari iOS No Samsung Internet Android Yes
name Chrome Yes Edge 14 Firefox 4 IE No Opera Yes Safari 5 WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS No Samsung Internet Android Yes
reportValidity Chrome 40 Edge 14 Firefox 4 IE No Opera 27 Safari 5 WebView Android 40 Chrome Android 40 Firefox Android 4 Opera Android 27 Safari iOS No Samsung Internet Android 4.0
setCustomValidity Chrome Yes Edge 14 Firefox 4 IE No Opera Yes Safari 5 WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS No Samsung Internet Android Yes
type Chrome Yes Edge 14 Firefox 4 IE No Opera Yes Safari 5 WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS No Samsung Internet Android Yes
validationMessage Chrome Yes Edge 14 Firefox 4 IE No Opera Yes Safari 5 WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS No Samsung Internet Android Yes
validity Chrome Yes Edge 14 Firefox 4 IE No Opera Yes Safari 5 WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS No Samsung Internet Android Yes
value Chrome Yes Edge 14 Firefox 4 IE No Opera Yes Safari 5 WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS No Samsung Internet Android Yes
willValidate Chrome Yes Edge 14 Firefox 4 IE No Opera Yes Safari 5 WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS No Samsung Internet Android Yes

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知
见实现注意事项。

另请参阅

  • The HTML element implementing this interface: <output> .
  1. HTMLOutputElement
  2. 特性
    1. labels
  3. 继承:
    1. HTMLElement
    2. Element
    3. Node
    4. EventTarget
  4. Related pages for HTML DOM
    1. BeforeUnloadEvent
    2. DOMStringMap
    3. ErrorEvent
    4. GlobalEventHandlers
    5. HTMLAnchorElement
    6. HTMLAreaElement
    7. HTMLAudioElement
    8. HTMLBRElement
    9. HTMLBaseElement
    10. HTMLBaseFontElement
    11. HTMLBodyElement
    12. HTMLButtonElement
    13. HTMLCanvasElement
    14. HTMLContentElement
    15. HTMLDListElement
    16. HTMLDataElement
    17. HTMLDataListElement
    18. HTMLDialogElement
    19. HTMLDivElement
    20. HTMLDocument
    21. HTMLElement
    22. HTMLEmbedElement
    23. HTMLFieldSetElement
    24. HTMLFormControlsCollection
    25. HTMLFormElement
    26. HTMLFrameSetElement
    27. HTMLHRElement
    28. HTMLHeadElement
    29. HTMLHeadingElement
    30. HTMLHtmlElement
    31. HTMLIFrameElement
    32. HTMLImageElement
    33. HTMLInputElement
    34. HTMLIsIndexElement
    35. HTMLKeygenElement
    36. HTMLLIElement
    37. HTMLLabelElement
    38. HTMLLegendElement
    39. HTMLLinkElement
    40. HTMLMapElement
    41. HTMLMediaElement
    42. HTMLMetaElement
    43. HTMLMeterElement
    44. HTMLModElement
    45. HTMLOListElement
    46. HTMLObjectElement
    47. HTMLOptGroupElement
    48. HTMLOptionElement
    49. HTMLOptionsCollection
    50. HTMLParagraphElement
    51. HTMLParamElement
    52. HTMLPictureElement
    53. HTMLPreElement
    54. HTMLProgressElement
    55. HTMLQuoteElement
    56. HTMLScriptElement
    57. HTMLSelectElement
    58. HTMLShadowElement
    59. HTMLSourceElement
    60. HTMLSpanElement
    61. HTMLStyleElement
    62. HTMLTableCaptionElement
    63. HTMLTableCellElement
    64. HTMLTableColElement
    65. HTMLTableDataCellElement
    66. HTMLTableElement
    67. HTMLTableHeaderCellElement
    68. HTMLTableRowElement
    69. HTMLTableSectionElement
    70. HTMLTemplateElement
    71. HTMLTextAreaElement
    72. HTMLTimeElement
    73. HTMLTitleElement
    74. HTMLTrackElement
    75. HTMLUListElement
    76. HTMLUnknownElement
    77. HTMLVideoElement
    78. HashChangeEvent
    79. History
    80. ImageData
    81. Location
    82. MessageChannel
    83. MessageEvent
    84. MessagePort
    85. Navigator
    86. NavigatorGeolocation
    87. NavigatorID
    88. NavigatorLanguage
    89. NavigatorOnLine
    90. NavigatorPlugins
    91. PageTransitionEvent
    92. Plugin
    93. PluginArray
    94. PopStateEvent
    95. PortCollection
    96. PromiseRejectionEvent
    97. RadioNodeList
    98. Transferable
    99. ValidityState
    100. Window
    101. WindowBase64
    102. WindowEventHandlers
    103. WindowTimers