[RESOLVIDO] DIV + JS
Amigo, estou com um probleminha e não consigo resolver...
já revirei a internet inteira, mas não encontrei nada parecido com o que preciso.
A questão é o seguinte. Queria executar um comando JS assim que uma div aparecer na tela.
Abaixo estou deixando os codes
<script src="js/jquery.min.js" type="text/javascript"></script>
<style>
#progress {
width:100%;
height:20px;
border: solid #808080 2px;
border-radius: 5px;
background-image: linear-gradient( 90deg, green, yellow, red );
}
#processador{
width: 0%;
height: 16px;
background-color: rgba(0, 0, 0, 0.5);
}
#memoria{
width: 0%;
height: 16px;
background-color: rgba(0, 0, 0, 0.5);
}
#hd{
width: 0%;
height: 16px;
background-color: rgba(0, 0, 0, 0.5);
}
</style>
Processador
<span data-bind="Usage"><div id="progress"><div id="processador"></div></div><div style="text-align:right;">20%</div></span>
Memória
<span data-bind="Usage"><div id="progress"><div id="memoria"></div></div><div style="text-align:right;">50%</div></span>
Hard Disk
<span data-bind="Usage"><div id="progress"><div id="hd"></div></div><div style="text-align:right;">80%</div></span>
JS
<script type="text/javascript">
$("#processador").html(function(){
alert("ok");
var width = 1;
var id = setInterval(frame, 10);
var id2 = setInterval(frame2, 10);
var id3 = setInterval(frame3, 10);
function frame() {
if (width >= 20) {
clearInterval(id);
} else {
width++;
document.getElementById("processador").style.width = width + '%';
}
}
function frame2() {
if (width >= 50) {
clearInterval(id2);
} else {
width++;
document.getElementById("memoria").style.width = width + '%';
}
}
function frame3() {
if (width >= 80) {
clearInterval(id3);
} else {
width++;
document.getElementById("hd").style.width = width + '%';
}
}
});
</script>
A "animação" em si, está funcionando perfeitamente, porém ao carregar a página e não no momento em que a DIV aparece na telaDiscussão (10)
Carregando comentários...