Kod
function start() {
for (var x = 0; x <= 250; x++) {
start_load(x);
}
}
function start_load(x) {
var a = document.getElementById("time").value;
var b = a / 250 * 1000; \\ czas w milisekundach dodawania 1 px paska
setTimeout(function() { document.getElementById("perc").style.width = x + "px" }, b);
}
for (var x = 0; x <= 250; x++) {
start_load(x);
}
}
function start_load(x) {
var a = document.getElementById("time").value;
var b = a / 250 * 1000; \\ czas w milisekundach dodawania 1 px paska
setTimeout(function() { document.getElementById("perc").style.width = x + "px" }, b);
}
Kod
<input id="time" type="text"/>
<div id="main" style="width: 250px">
<div id="perc" style="float: left; height: 100%; width: 0; background: green"></div>
</div>
<button onclick="start()"><b>start</b></button>
<div id="main" style="width: 250px">
<div id="perc" style="float: left; height: 100%; width: 0; background: green"></div>
</div>
<button onclick="start()"><b>start</b></button>
Obecnie działa to tak, że dla małych wartości pasek po prostu robi się zielony, a dla większych robi się od razu zielony tylko z jakimś tam opóźnieniem. Co robię nie tak? Dzięki z góry za odp
