【发布时间】:2014-02-14 22:29:46
【问题描述】:
我是 jquery 和 localstorage 的新手。我想使用本地存储到所有使用 jquery 的文本框。
<input id="in-1" type="text" />
<br />
<input id="in-2" type="text" />
<br />
<input id="in-3" type="text" />
<br />
<input id="in-4" type="text" />
<br />
我正在尝试遵循这个脚本:
(function ($) {
if (typeof (window.localStorage) != "undefined") {
$.each($("input[type=text]"), function () {
localStorage.getItem($(this).attr("id")));
});
$("input[type=text]").on("change", function () {
localStorage.setItem($(this).attr("id"), $(this).val());
});
}
})(jQuery);
但我无法完成这项工作。
【问题讨论】:
标签: jquery textbox local-storage