Easy and Simple Digital Clock

1 post Page 1 of 1
Contributors
User avatar
mikethedj4
VIP - Site Partner
VIP - Site Partner
Posts: 2592
Joined: Thu Mar 25, 2010 4:36 am

Easy and Simple Digital Clock
mikethedj4
In Action - http://jsbin.com/IriqOcI/1/
View/Edit code - http://jsbin.com/IriqOcI/1/edit

Full Code:
Code: Select all
<!DOCTYPE html>
<html>
<head>
<title>Digital Clock</title>
<script>
// Define a function to display the current time
function displayTime() {
	var elt = document.getElementById('clock');
	var now = new Date();
	elt.innerHTML = now.toLocaleTimeString();
	setTimeout(displayTime, 1000);
}
window.onload = displayTime;
</script>
<style>
#clock {
	font: bold 1.5em sans;
}
</style>
</head>
<body>
	<span id='clock'></span>
</body>
</html>
1 post Page 1 of 1
Return to “Tutorials”