HTML5 localStorage 本地存储

1、设置localStorage

//方法一
localStorage.setItem("t1","1111111");
//方法二
localStorage.t1="1111111";

//方法三
localStorage['t1']="1111111";

2、获取localStorage

//方法一
localStorage.getItem("t1","1111111");
//方法二
localStorage.t1;
//方法三
localStorage['t1'];

3、相关操作

localStorage.removeItem("t1"); //删除指定
localStorage.clear();//删除所有
localStorage.length;//获取多少条记录
localStorage.key(0);//获取存储在键内容

 

posted @ 2015-11-29 12:48  FinnYY  阅读(160)  评论(0编辑  收藏  举报