尝试自学 JavaScript。但是,我无法弄清楚为什么以下代码不起作用。有什么想法吗?
<!DOCTYPE html>
<html>
<body>
<p> Click the button to display the date</p>
<button onclick="showDate()">HIT ME</button>
<script>
function displayDate()
{
document.getElementById("test").innterHTML=displayDate();
}
</script>
<p id="test"></p>
</body>
复制粘贴错误,以下是实际代码:
<!DOCTYPE html>
<html>
<body>
<p> Click the button to display the date</p>
<button onclick="showDate()">HIT ME</button>
<script>
function showDate()
{
document.getElementById("test").innterHTML=Date();
}
</script>
<p id="test"></p>
</body>
最佳答案
document.getElementById("test").innterHTML=Date();
应该是
document.getElementById("test").innerHTML=Date();
关于javascript - 在javascript中显示日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22620663/