+ 1
Clock in web by java script
hello guys i have a digital clock on my website.i created it with java script. when i insert the script code in my html code,after running the page, after one second everything will lost. I don't know what is the problem, help me. this is the java script code: function printTime(){ var date = new Date(); var h = date.getHours(); var m = date.getMinutes(); var s = date.getSeconds(); document.body.innerHTML = h + ":" + m + ":" + s; } function clock() { setInterval(printTime ,1000); }
3 Réponses
+ 11
I just checked it and works perfectly fine...
+ 3
and this is my html code:
<div>
<script>
clock();
</script>
</div>
0
<script>标签放在<body>里