Skip to content

Latest commit

 

History

History
70 lines (56 loc) · 2.56 KB

File metadata and controls

70 lines (56 loc) · 2.56 KB
title slug
<output>
Web/HTML/Element/output

{{HTMLSidebar}}

HTML <output> 标签表示计算或用户操作的结果。

Content categories 流式元素短语元素listed, labelable, resettable form-associated element, palpable content.
允许元素 短语元素
标签省略 不允许,开始标签和结束标签都不能省略。
允许父元素 接受任何 短语元素
允许 ARIA 角色 Any
DOM 接口 {{domxref("HTMLOutputElement")}}

属性

这个标签具有 全局属性

  • for
    • : 其他影响计算结果的标签的 ID,可以多个。
  • form
    • : 与当前标签有关联的 form(从属的表单)。该属性的值必须是当前文档内的表单元素的 ID。如果未指明该属性,output 标签必须是一个 form 的后代标签。该属性的用处在于可以让 output 标签脱离 form 标签,存在于一个网页文档的任意位置。
  • name
    • : name 属性。

例子

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

规范

{{Specifications}}

浏览器兼容性

{{Compat}}

参见

  • Other form-related elements: {{HTMLElement("form")}}, {{HTMLElement("input")}}, {{HTMLElement("button")}}, {{HTMLElement("datalist")}}, {{HTMLElement("legend")}}, {{HTMLElement("label")}}, {{HTMLElement("select")}}, {{HTMLElement("optgroup")}}, {{HTMLElement("option")}}, {{HTMLElement("textarea")}}, {{HTMLElement("fieldset")}}, {{HTMLElement("progress")}} and {{HTMLElement("meter")}}.