HTMLOutputElement: labels 属性
HTMLOutputElement.labels
只读属性返回一个与 <output>
元素关联的 <label>
元素的
。NodeList
值
一个包含与 <output>
元素关联的 <label>
元素的
。NodeList
示例
HTML
html
<label id="label1" for="test">Label 1</label>
<output id="test">Output</output>
<label id="label2" for="test">Label 2</label>
JavaScript
js
const output = document.getElementById("test");
for (const label of output.labels) {
console.log(label.textContent); // "Label 1" and "Label 2"
}
规范
规范 |
---|
HTML # dom-lfe-labels-dev |
浏览器兼容性
加载中…