xmas12 Posted March 13, 2011 Report Posted March 13, 2011 Sveiki, vai varat iedot, kkādu paraugu, kur ir parādīts kā javascript izpilda timeri. Tas ir tā, ka piemēram no 20 sekundēm atskaita lidz 0 un tad vnk paradās kautkāds teksts? Quote
0 snach15 Posted March 13, 2011 Report Posted March 13, 2011 http://davidwalsh.name/jquery-countdown-plugin Quote
0 indoom Posted March 14, 2011 Report Posted March 14, 2011 <div id="sek">20</div> <script type="text/javascript"> var taimers = null; function skaitamSek(sec){ if (taimers) { clearTimeout(taimers); } taimers = setTimeout(function(){ document.getElementById('sek').innerHTML = --sec; if (sec <= 0) { document.getElementById('sek').innerHTML = 'Done'; } else { skaitamSek(sec); } },1000); } skaitamSek(20); </script> Quote
0 v3rb0 Posted March 14, 2011 Report Posted March 14, 2011 setInterval(): <div id="sek">20</div> <script type="text/javascript"> var s = document.getElementById("sek"), interval = window.setInterval(function(){ if (s.innerHTML <= 0) { window.clearInterval(interval); s.innerHTML = 'Done'; } else { s.innerHTML = --s.innerHTML; } }, 1000); </script> Quote
Question
xmas12
Sveiki, vai varat iedot, kkādu paraugu, kur ir parādīts kā javascript izpilda timeri. Tas ir tā, ka piemēram no 20 sekundēm atskaita lidz 0 un tad vnk paradās kautkāds teksts?
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.