JavaScript: Exemplo de uso do clearInterval
From AdonaiMedrado.Pro.Br
Revision as of 23:30, 12 September 2008 by Adonaimedrado (Talk | contribs) (New page: <code lang="javascript"> <html> <head> <title>Minha Página</title> </head> <body> <input type="text" id="txtMeuContador" /> <input type="button" id="btOK" value="OK" o...)
<html> <head> <title>Minha Página</title> </head> <body> <input type="text" id="txtMeuContador" /> <input type="button" id="btOK" value="OK" onclick="javascript:f2();" /> <script language="javascript"> var i = 0; var intervalId; function f1() { document.getElementById("txtMeuContador").value = i++; } function f2() { clearInterval(intervalId); } intervalId = setInterval(f1, 500); </script> </body> </html>