Create a Progress Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Progress

Introduction

You can create a <progress> element by using the document.createElement() method:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">create a PROGRESS element with a maximum value of "100" and a current value of "42"</button>

<script>
function myFunction() {//from  w ww .  ja va  2 s  .c om
    var x = document.createElement("PROGRESS");
    x.setAttribute("value", "42");
    x.setAttribute("max", "100");
    document.body.appendChild(x);
}
</script>

</body>
</html>

Related Tutorials