[英]Setting HTML content with Javascript
I would like to echo a clock inside a <div id="details">
, and the script for doing the same at title is like this:- 我想在
<div id="details">
内回显一个时钟,并且在title处执行相同操作的脚本是这样的:-
<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 会做到的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.