<!doctypehtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>Document</title>
</head>
<body>
賬號:<input>
密碼:<input>
記住密碼:<inputtype="checkbox">
<buttononclick="fn()">登錄</button>
<script>
varuser=document.getElementsByTagName("input")[0],
pass=document.getElementsByTagName("input")[1],
check=document.getElementsByTagName("input")[2],
loUser=localStorage.getItem("user")||"";
loPass=localStorage.getItem("pass")||"";
user.value=loUser;
pass.value=loPass;
if(loUser!==""&&loPass!==""){
check.setAttribute("checked","");
}
functionfn(){
if(check.checked){
localStorage.setItem("user",user.value);
localStorage.setItem("pass",pass.value);
}else{
localStorage.setItem("user","");
localStorage.setItem("pass","");
}
}
</script>
</body>
</html>