I would like to echo a clock inside a <div id="details">
, and the script for doing the same at title is like this:-
<html>
<head>
<title>Showing time at title</title>
<script language="javascript">
function showTimes(){
myDate= new Date()
realTimes= "Time now " + myDate.getHours() + " : "
realTimes= realTimes + myDate.getMinutes() + " : "
realTimes= realTimes + myDate.getSeconds() + "."
realTimes= realTimes + myDate.getMilliseconds()
document.title=realTimes
setTimeout("showTimes()",100)
}
</script>
</head>
<body onLoad="showTimes()">
<img src="img/s8.jpg">
</body>
</html>
how shall I rewrite the script?? Thanksalot...
您正在尝试设置document.getElementById('details').innerHTML
。
replace
document.title=realTimes
with
document.getElementById("details").innerHTML=realTimes
Replacing
document.title=realTimes`
with
document.getElementById('details').innerHTML=realTimes
would do the trick
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.