xmas12 Posted March 13, 2011 Report Share 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 Link to comment Share on other sites More sharing options...
0 m8t Posted March 13, 2011 Report Share Posted March 13, 2011 http://tinyurl.com/czefb3 Quote Link to comment Share on other sites More sharing options...
0 snach15 Posted March 13, 2011 Report Share Posted March 13, 2011 http://davidwalsh.name/jquery-countdown-plugin Quote Link to comment Share on other sites More sharing options...
0 rpr Posted March 14, 2011 Report Share Posted March 14, 2011 setTimeout() ? Quote Link to comment Share on other sites More sharing options...
0 indoom Posted March 14, 2011 Report Share 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 Link to comment Share on other sites More sharing options...
0 v3rb0 Posted March 14, 2011 Report Share 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 Link to comment Share on other sites More sharing options...
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?
Link to comment
Share on other sites
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.