我是jquery和localstorage的新手。我想对所有使用jquery的文本框使用localstorage。
我正在尝试遵循以下脚本:
(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);
但是我做不到这一点。