我正在尝试将段落的内容更改为输入字段提交的文本输入字段的值。段落将暂时更改,然后页面将刷新,更改将被还原。我该如何保留更改?谢谢!
这是我的代码:
<!DOCTYPE html>
<html>
<body>
<form onsubmit = "myFunction()">
<input id = "input" type = "text">
</form>
<p id = "change"> This should be changed on submit</p>
<script>
function myFunction() {
document.getElementById("change").innerHTML = document.getElementById("input").value;
}
</script>
</body>
</html>