这是我用来在我的 html 页面上动态发布一行的代码,问题是当我刷新它时页面变空,我希望该行永久地写在页面上
<html>
<br><br>post a question <br>
<br><br><textarea id="t"></textarea><br>
<br><br><button id='a'>Post</button>
<div id='updateDiv'></div>
<script language= "javascript">
function displayDate()
{
var comment = document.getElementById("t").value;
var newParagraph = document.createElement('p');
newParagraph.textContent = comment;
document.getElementById("updateDiv").appendChild(newParagraph);
document.getElementById("t").value = "";
}
document.getElementById("a").onclick = displayDate;
</script>
</html>