这是培训的第二课,这节课老师介绍了javascript这门语言。从生动的实例中我发现了这门语言的强大,仅仅几行代码就能写出网页时钟,真是太神奇了,我对这门语言开始产生了兴趣。
<html>
<head>
<title>网页时钟</title>
<style>
#time{
background-color: #6C0;
border:1px #555 dashed;
width:300px;
height:34px;
}
</style>
</head>
<body>
<div id="time"></div>
<script>
function dispTime(){
var timestr=new Date().toLocaleString();
document.getElementById("time").innerHTML=timestr;
setTimeout("dispTime()","1000")
//setInterval("dispTime()","1000");
dispTime();
</script>
</body>
</html>