HTMLMeterElement: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.
值
一个 NodeList
,包含与 <meter>
元素关联的 <label>
元素。
示例
HTML
html
<label id="label1" for="test">标签 1</label>
<meter id="test" min="0" max="100" value="70">70</meter>
<label id="label2" for="test">标签 2</label>
JavaScript
js
window.addEventListener("DOMContentLoaded", () => {
const meter = document.getElementById("test");
for (const label of meter.labels) {
console.log(label.textContent); // “标签 1”和“标签 2”
}
});
规范
Specification |
---|
HTML # dom-lfe-labels-dev |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
labels |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.