无法使用本地存储中的JavaScript填充电子邮件字段

无法使用本地存储中的JavaScript填充电子邮件字段,javascript,html,Javascript,Html,我有两个文件test.html和test2.html。我可以保存表单的值,但不能填充test2.html表单中的输入字段 Test.html <script type="text/javascript"> function store(){ var inputEmail= document.getElementById("email"); localStorage.setItem("email", inputEmail.value); }

我有两个文件test.html和test2.html。我可以保存表单的值,但不能填充test2.html表单中的输入字段

Test.html

    <script  type="text/javascript">
  function store(){
     var inputEmail= document.getElementById("email");

     localStorage.setItem("email", inputEmail.value);
    }
</script>
<form action="test2.html" class="form-login"  method="post" /> 
<input name="email" type="email" id="email" required="" placeholder="Email" />

<button onclick="store()" type="button">StoreEmail</button>

函数存储(){
var inputEmail=document.getElementById(“电子邮件”);
localStorage.setItem(“email”,inputEmail.value);
}
StoreEmail
Test2.html

      <script type="text/javascript">
      function get(){

         var storedValue = localStorage.getItem("email");

         document.getElementById("email").innerHTML = storedValue;
         document.getElementById("email").value = storedValue;

        }
    </script>
    <p id="email">qqqqqq</p>
    <form action="" class="form-login"  method="post" /> 
    <input name="email" type="email" id="email" placeholder="Email" />

<button onclick="get()" type="button">getEmail</button>

函数get(){
var storedValue=localStorage.getItem(“电子邮件”);
document.getElementById(“email”).innerHTML=storedValue;
document.getElementById(“email”).value=storedValue;
}

qqq

获取电子邮件

当我单击getEmail按钮时,段落会更改,但电子邮件输入字段不会随值更改。请提供帮助。

每个DOM节点的id在整个DOM中都应该是唯一的

document.getElementById始终返回第一个匹配的dom节点