HTMLOutputElement:labels 属性
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2018.
HTMLOutputElement.labels
只读属性返回一个包含与 元素关联的
元素的
NodeList
。
值
一个包含与 元素关联的
元素的
NodeList
。
示例
HTML
html
JavaScript
js
window.addEventListener("DOMContentLoaded", () => {
const output = document.getElementById("test");
for (const label of output.labels) {
console.log(label.textContent); // “标签 1”和“标签 2“
}
});
规范
Specification |
---|
HTML # dom-lfe-labels-dev |