<input type="checkbox" name="remember" value="remember"> 记住密码 <input type="submit" id="submit" value="提交" /> <script> var rem = document.querySelector("input[name=remember]"); rem.checked = Boolean( localStorage.getItem(o.value) ) || false; document.querySelector("#submit").onclick = function() { localStorage.setItem( rem.value, rem.checked ); } </script>