//保存
//获取用户名密码
user_name = $("input[name='user_name']").val();
user_pass = $("input[name='user_pass']").val();
//判断浏览器是否支持localStorage
if(window.localStorage){
//判断是否保存密码
if ($("input[name='storage']").prop('checked')) {
//保存
localStorage.user_name = user_name;
localStorage.user_pass = user_pass;
localStorage.storage = 1;
}else{
//清空
localStorage.clear();
}
}
//读取保存数据
//判断浏览器是否支持localStorage
if(window.localStorage){
//之前存的,判断是否保存密码
if (localStorage.storage) {
$("input[name='storage']").prop('checked',true);
}else{
$("input[name='storage']").prop('checked',false);
}
//读取并赋值
$("input[name='user_name']").val(localStorage.user_name);
$("input[name='user_pass']").val(localStorage.user_pass);
}