HTMLProgressElement: value property
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Thuộc tính value của giao diện HTMLProgressElement đại diện cho tiến trình hiện tại của phần tử <progress>.
Giá trị
Một số dấu phẩy động. Nếu giá trị max không được đặt trên thanh tiến trình thì giá trị dao động trong khoảng 0.0 đến 1.0. Nếu giá trị max được đặt thì value dao động trong khoảng 0 đến giá trị max.
Nếu thuộc tính value không được đặt trên đối tượng HTMLProgressElement, thanh tiến trình vẫn ở trạng thái không xác định.
Ví dụ
>HTML
html
Determinate Progress bar: <progress id="pBar"></progress> <span>0</span>%
<br />
Indeterminate Progress bar: <progress></progress>
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 = Math.trunc(pBar.position * 100);
}, 100);
Thông số kỹ thuật
| Specification |
|---|
| HTML> # dom-progress-value> |