<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div>
用户名:
<input type="text" id="username">
</div>
<div>
密码:
<input type="password" id="password">
</div>
<div>
<button id="login">登录</button>
</div>
<script>
login.onclick = function(){
console.log(username.value,password.value)
localStorage.setItem("username",username.value)
localStorage.setItem("password",password.value)
}
</script>
</body>
</html>
输入用户名密码,点击登录值就存在浏览器中