localStorage: //离线存储 浏览器关闭保留
存储:
localStorage["a"] = "aaaa"; //设置a为"sfsf",覆盖上面的值
localStorage.setItem("a","aaaa"); //设置b为"isaac"
获取:
var a = localStorage["a"]; //获取a的值
var a = localStorage.a; //获取a的值
var a = localStorage.getItem("a"); //获取a的值
删除:
localStorage.removeItem("a"); //清除a的值
localStorage.clear() //删除所有
sessionStorage: //在线存储 浏览器关闭或删除
存储:
sessionStorage["a"] = "aaaa"; //设置a为"sfsf",覆盖上面的值
sessionStorage.setItem("a","aaaa"); //设置b为"isaac"
获取:
var a = sessionStorage["a"]; //获取a的值
var a = sessionStorage.a; //获取a的值
var a = sessionStorage.getItem("a"); //获取a的值
删除:
sessionStorage.removeItem("a"); //清除a的值
sessionStorage.clear() //删除所有