javascriptは随筆を勉強します.
1227 ワード
<html>
<head>
<script type="text/javascript">
function startTime()
{
var today=new Date()//
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()//
// add a zero in front of numbers<10
m=checkTime(m)
s=checkTime(s)
document.getElementById('txt').innerHTML=h+":"+m+":"+s
t=setTimeout('startTime()',500)//0.5 0.5
}
function checkTime(i)
{
if (i<10)
{i="0" + i}
return i
}// , 10 0
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html>
時計を作るために時計を使います.<html>
<body>
<script type="text/javascript">
function person(firstname,lastname,age,eyecolor)
{
this.firstname=firstname
this.lastname=lastname
this.age=age
this.eyecolor=eyecolor
}
myFather=new person("John","Adams",35,"black")
document.write(myFather.firstname + " " + myFather.age + " 。")
</script>
</body>
</html>
オブジェクト用のテンプレートを作成します.