InnerHTML更改还原表单提交

时间:2016-03-15 04:39:30

标签: javascript html forms submit innerhtml

我正在尝试将段落的内容更改为输入字段提交的文本输入字段的值。段落将暂时更改,然后页面将刷新,更改将被还原。我该如何保留更改?谢谢!

这是我的代码:

<!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> 

0 个答案:

没有答案