HTMLProgressElement: position 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 chỉ đọc position của giao diện HTMLProgressElement trả về tiến trình hiện tại của phần tử <progress>.

Giá trị

Đối với thanh tiến trình xác định, trả về kết quả của giá trị hiện tại chia cho giá trị tối đa, tức là một phân số giữa 0.01.0.

Đối với thanh tiến trình không xác định, giá trị luôn là -1.

Ví dụ

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);

Thông số kỹ thuật

Thông số kỹ thuật
HTML
# dom-progress-position-dev

Tương thích trình duyệt