Javascript DOM HTML Progress Object create

Introduction

We can create a <progress> element via the document.createElement() method:

var x = document.createElement("PROGRESS");

Click the button to create a PROGRESS element with a maximum value of "100" and a current value of "20".

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/* w  w w.  j  a va 2  s .  c  o  m*/
  var x = document.createElement("PROGRESS");
  x.setAttribute("value", "20");
  x.setAttribute("max", "100");
  document.body.appendChild(x);
}
</script>

</body>
</html>



PreviousNext

Related