Bagaimana membuat jam digital dengan html dan javascript?
berikut source code nya,
buka text editor anda, standart nya notepad / ++
copy code di bawah, lalu pastekan ke editor anda, lalu save dengan extension .html
lalu buka..
<html>
<head>
<title>Jam Digital</title>
<script type="text/javascript">
function digital_clock()
{
var date=new Date();
var hours=date.getHours();
var minutes=date.getMinutes();
var seconds=date.getSeconds();
hours=addZero(hours);
minutes=addZero(minutes);
seconds=addZero(seconds);
document.getElementById('hours').innerHTML = hours;
document.getElementById('minutes').innerHTML = minutes;
document.getElementById('seconds').innerHTML = seconds;
setTimeout('digital_clock()',500);
}
function addZero(date_part)
{
if(date_part < 10)
{
date_part="0" + date_part;
}
return date_part;
}
</script>
</head>
<body onload="digital_clock()" bgcolor=gray>
<center>
<h1> Jam dengan HTML dan Javascript </h1>
<div style="border:black 2px solid;width:100;background-color:white">
<b id=hours> </b> :
<b id=minutes> </b> :
<b id=seconds> </b>
</div>
by ho1onk
</center>
</body>
</html>
berikut source code nya,
buka text editor anda, standart nya notepad / ++
copy code di bawah, lalu pastekan ke editor anda, lalu save dengan extension .html
lalu buka..
<html>
<head>
<title>Jam Digital</title>
<script type="text/javascript">
function digital_clock()
{
var date=new Date();
var hours=date.getHours();
var minutes=date.getMinutes();
var seconds=date.getSeconds();
hours=addZero(hours);
minutes=addZero(minutes);
seconds=addZero(seconds);
document.getElementById('hours').innerHTML = hours;
document.getElementById('minutes').innerHTML = minutes;
document.getElementById('seconds').innerHTML = seconds;
setTimeout('digital_clock()',500);
}
function addZero(date_part)
{
if(date_part < 10)
{
date_part="0" + date_part;
}
return date_part;
}
</script>
</head>
<body onload="digital_clock()" bgcolor=gray>
<center>
<h1> Jam dengan HTML dan Javascript </h1>
<div style="border:black 2px solid;width:100;background-color:white">
<b id=hours> </b> :
<b id=minutes> </b> :
<b id=seconds> </b>
</div>
by ho1onk
</center>
</body>
</html>
Menampilkan Waktu Saat ini dengan javascript
4/
5
Oleh
Holong.Me