JavaScript Program to Demonstrate Use of setInterval() method

Write a JavaScript program to demonstrate use of setinterval() method.



Source Code
<html>
<head>
    <title>setInterval() method</title>
</head>
<body>
<h2 id="panel"></h2>
    <script>
        var id = setInterval('timer()', 1000)

        function timer()
        {
            var panel = document.getElementById('panel')
            var d = new Date()
            panel.innerHTML = d.toLocaleTimeString()
        }
    </script>
</body>
</html>
Output





"Coding Hub - Learn to code" app now available on Google Play Store