fork download
  1. <!DOCTYPE html>
  2. <head>
  3. <meta charset="UTF-8">
  4. </head>
  5. <body>
  6. <button onclick="StartInterval();">Start</button>
  7. <button onclick="StopInterval();">Stop</button>
  8. <br>
  9. <div id="Dsp"></div>
  10. </body>
  11. <script>
  12. var oTestInterval;
  13. eDsp = document.getElementById("Dsp");
  14. function StartInterval() {
  15. console.log("StartInterval()");
  16. if (!oTestInterval) {
  17. console.log("if (!oTestInterval)");
  18. oTestInterval = setInterval(() => {
  19. eDsp.innerHTML += "*";
  20. }, 1000);//ms
  21. }
  22. }
  23. function StopInterval() {
  24. if (oTestInterval) {
  25. clearInterval(oTestInterval);
  26. oTestInterval = null;
  27. }
  28. }
  29. </script>
  30. </html>
  31.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty