Javascript examples for DOM:Element innerHTML
Stop setinterval in innerhtml
<html> <head> <meta name="viewport" content="width=device-width"> </head> <body> <div id="time"></div> <script> let time = 0;//from w w w .j av a 2s. com let int = setInterval(() => { if(time === 10) clearInterval(int); document.getElementById('time').innerHTML = 'seconds: ' + time; time++ }, 1000) </script> </body> </html>