当前位置:主页 > 网页前端 > JavaScript代码 >

innerText 使用示例

时间:2021-04-16 08:25:51 | 栏目:JavaScript代码 | 点击:

复制代码 代码如下:

<html>
<head>
<script language = "javascript" type = "text/javascript">
function showTime(){
//在元素间的文本就是通过 对象 .innerText
document.getElementById("mytime").innerText = new Date().toLocaleString();
}
setInterval("showTime()",1000);
</script>
</head>
<body>
<span id = "mytime"></span>
</body>
</html>

您可能感兴趣的文章:

相关文章