HTMLProgressElement: max 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 max của giao diện HTMLProgressElement đại diện cho giới hạn trên của phạm vi phần tử <progress>.

Giá trị

Một số dấu phẩy động lớn hơn 0. Giá trị mặc định là 1.0.

Ví dụ

HTML

html
Progress: <progress id="pBar"></progress> <span>0</span>%

JavaScript

js
const pBar = document.getElementById("pBar");
const span = document.getElementsByTagName("span")[0];

console.log(`Default value of max: ${pBar.max}`);

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-max

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