HTMLProgressElement: position 属性
HTMLProgressElement 接口的只读属性 position 返回 <progress> 元素的当前进度。
值
对于确定的进度条,它返回当前值除以最大值的计算结果,即一个介于 0.0 和 1.0 之间的分数。
对于不确定的进度条,该值始终为 -1。
示例
HTML
html
Determinate Progress bar: <progress id="pBar"></progress> Position:
<span>0</span>
JavaScript
js
const pBar = document.getElementById("pBar");
const span = document.getElementsByTagName("span")[0];
pBar.max = 100;
pBar.value = 0;
setInterval(() => {
pBar.value = pBar.value < pBar.max ? pBar.value + 1 : 0;
span.textContent = pBar.position;
}, 100);
规范
| 规范 |
|---|
| HTML # dom-progress-position-dev |
浏览器兼容性
加载中…