<output>: The Output element - HTML: HyperText Markup Language 编辑

The HTML Output element (<output>) is a container element into which a site or app can inject the results of a calculation or the outcome of a user action.

Content categoriesFlow content, phrasing content, listed, labelable, resettable form-associated element, palpable content.
Permitted contentPhrasing content.
Tag omissionNone, both the starting and ending tag are mandatory.
Permitted parentsAny element that accepts phrasing content.
Implicit ARIA rolestatus
Permitted ARIA rolesAny
DOM interfaceHTMLOutputElement

Attributes

This element includes the global attributes.

for
A space-separated list of other elements’ ids, indicating that those elements contributed input values to (or otherwise affected) the calculation.
form
The <form> element to associate the output with (its form owner). The value of this attribute must be the id of a <form> in the same document. (If this attribute is not set, the <output> is associated with its ancestor <form> element, if any.)
This attribute lets you associate <output> elements to <form>s anywhere in the document, not just inside a <form>. It can also override an ancestor <form> element.
name
The element's name. Used in the form.elements API.

The <output> value, name, and contents are NOT submitted during form submission.

Examples

In the following example, the form provides a slider whose value can range between 0 and 100, and an <input> element into which you can enter a second number. The two numbers are added together, and the result is displayed in the <output> element each time the value of any of the controls changes.

<form oninput="result.value=parseInt(a.value)+parseInt(b.value)">
  <input type="range" id="b" name="b" value="50" /> +
  <input type="number" id="a" name="a" value="10" /> =
  <output name="result" for="a b">60</output>
</form>

Accessibility Concerns

Many browsers implement this element as an aria-live region. Assistive technology will thereby announce the results of UI interactions posted inside it without requiring that focus is switched away from the controls that produce those results.

Specifications

SpecificationStatusComment
HTML Living Standard
The definition of '<output>' in that specification.
Living Standard
HTML5
The definition of '<output>' in that specification.
Recommendation

Browser compatibility

BCD tables only load in the browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:58 次

字数:6142

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文