javascript - 使用 Javascript 将 LocalStorage 值插入表单输入字段

标签 javascript jquery html

我在 localStorage 中存储一个值。

我希望使用 Javascript 将该值插入到输入字段值中。我该怎么做?

演示:http://jsfiddle.net/5apg1mh3/

localStorage.setItem("email", "test");
<input type="text" value="" id="email" name="email"/>

最佳答案

document.getElementById('email').setAttribute('value', localStorage.getItem('email'));

关于javascript - 使用 Javascript 将 LocalStorage 值插入表单输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46695015/

相关文章:

javascript - 如何在 javascript 和 php 中加密和解密 id

php - jQuery(用户界面): Javascript Variable convert to PHP Variable

javascript - 使用 JQuery 检查 url 是否包含字符串

jquery - jqGrid更新字段 "editable:false"

javascript - 在 JavaScript 中显示 Combobox 项目的文本 onchange()

javascript - 使用 jQuery 打印行

javascript - meteor JS : How to get value of an input text

javascript - clearInterval 在 jquery 中不起作用

python - Django静态图像不显示

html - 视差效果在 Firefox 中不起作用