Why is my progress bar displayed only after it's reached 100%?
<html>
<style type="text/css">
#bar{
width: 10px;
height: 14px;
color: white;
font-size: 12px;
overflow: hidden;
background-color: red;
padding-left: 5px;
}
</style>
<head>
<script>
function setPercent(num){
document.getElementById("bar").style.width = num+ "px";
document.getElementById("bar").innerHTML= num + "%";
}
</script>
</head>
<body>
<div id="bar"></div>
<script>
var i = 0
while ( i < 100)
{
setPercent(i)
i++
}
alert("DONE")
</script>
</body>
</html>