【发布时间】:2020-06-25 09:45:47
【问题描述】:
test.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>This is test Page for Learn JS</title>
<script type="text/javascript" src="/learn/test.js"></script>
</head>
<body>
<input type="button" value="Time" onclick="daytime()">
<p id="now"></p>
</body>
</html>
这是 test.js
function daytime() {
document.getElementById("now").innerHTML=Date();
}
为什么点击按钮,没关系。 但是将js代码插入html,它正在工作
【问题讨论】:
-
请在提问前详细说明您的问题并进行研究。这里已经回答了很多问题,做一些研究。在提问之前,也可以先看看 js 的简短教程。
-
改用
new Date().toString()。
标签: javascript html