LocalStorage的用法:
https://www.jianshu.com/p/39ba41ead42e
例子:
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<title></title>
<script src="../js/jquery-1.12.4.js"></script>
</head>
<body>
<input type="text" id="name" value="" /><br />
<input type="text" id="age" value="" /><br />
<button id="read">读取</button>
<button id="clear">清除储存</button>
<div id="local"></div>
<script type="text/javascript">
$(function(){
$('#read').bind('click',function(){
var name = $('#name').val();
var age = $('#age').val();
localStorage.setItem('name',name);
localStorage.setItem('age',age);
$('#local').text(localStorage.getItem('name')+'---'+localStorage.getItem('age'));
});
$('#clear').bind('click',function(){
localStorage.clear();
$('#local').text(localStorage.getItem('name')+'---'+localStorage.getItem('age'));
});
});
</script>
</body>
</html>
效果图: