DEGITAL CLOCK SCRIPT
00
:
00
:
00
<!DOCTYPE html><html>
<head>
<title>Clock</title>
<script>
var d,h,m,s,animate;
function init(){
d=new Date();
h=d.getHours();
m=d.getMinutes();
s=d.getSeconds();
clock(); };
function clock(){
s++;
if(s==60){
s=0;
m++;
if(m==60){
m=0;
h++;
if(h==24){
h=0;
}
}
}
$('sec',s);
$('min',m);
$('hr',h);
animate=setTimeout(clock,1000);
};
function $(id,val){
if(val<10){
val='0'+val;
}
document.getElementById(id).innerHTML=val;
};
window.onload=init;
</script>
<link type="text/css" rel="stylesheet" href="style.css">
<style>
*{
margin:0;
padding:0;
font-family:
sans-serif;
font-size:40px;
}
.clock{
text-align:center;
width:auto;
height:auto; }</style>
</head>
<body>
<div class="clock">
<span id="hr">00</span>
<span> : </span>
<span id="min">00</span>
<span> : </span>
<span id="sec">00</span>
</div>
</body>
</html>
No comments:
Post a Comment