setInterval(): Demo

This demo preserves the original Click to Start behavior. The callback is now a function rather than the legacy string 'disp()', and repeated clicks do not create overlapping intervals.

Complete Working Source Top ↑

<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>setInterval Demo</title></head>
<body>
<button type="button" id="startBtn">Click to Start</button>
<div id="n1"></div>
<script>
let timerId = null;
const output = document.getElementById("n1");
document.getElementById("startBtn").addEventListener("click", () => {
  if (timerId !== null) return;
  timerId = window.setInterval(() => {
    output.append(document.createTextNode(" plus2net.com "));
  }, 1000);
});
</script>
</body>
</html>

setInterval() clearInterval()




Subscribe to our YouTube Channel here



plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer