Difference between revisions of "JavaScript: Exemplo de uso do clearInterval"

From AdonaiMedrado.Pro.Br
Jump to: navigation, search
(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...)
 
(No difference)

Latest revision as of 23:30, 12 September 2008

<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>