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.

We’d love to hear your thoughts on the next set of proposals for the JavaScript language. You can find a description of the proposals here.
Please take two minutes to fill out our short survey.

The position read-only property of the HTMLProgressElement interface returns current progress of the <progress> element.

Value

For determinate progress bar returns the result of current value divided by max value, i.e., a fraction between 0.0 and 1.0.

For indeterminate progress bar the value is always -1.

Examples

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

Specifications

Specification
HTML
# dom-progress-position-dev

Browser compatibility