Javascript DOM HTML Progress position Property get

Introduction

Get the current position of the progress bar:

var x = document.getElementById("myProgress").position;

Click the button to get the current position of the progress bar.

The value returned is the result of dividing the current value (22) by the maximum value (100).

View in separate window

<!DOCTYPE html>
<html>
<body>

Downloading progress:/*from  w  ww  .  j a va  2s  .  c  o m*/
<progress id="myProgress" value="22" max="100">
</progress>
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("myProgress").position;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The position property returns the current position of the progress bar.

The position property a floating point number, representing the current position of the progress bar.

The value of this property is the result of dividing the current value by the maximum value.

This property is read-only.




PreviousNext

Related