Digital Clock by me Using Vanilla Javascript
This is a very cute looking digital clock, I have used vanilla javascript to do so.
Function Description
function clock(){ var hours = document.getElementById('hour'); var minutes = document.getElementById('minutes'); var seconds = document.getElementById('seconds'); var h = new Date().getHours(); var m = new Date().getMinutes(); var s = new Date().getSeconds(); hours.innerHTML = h; minutes.innerHTML = m; seconds.innerHTML = s; } var interval = setInterval(clock, 1000);
Here i have created a date object and using DOM i have passed these to the html page. Here the setInterval() function is recalling the clock() function after every 1 sec.
Hope you may love this ;)
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login.