+ 24

How to use and destroy web storage in Html5?

5th Mar 2019, 8:39 AM
A͢J
A͢J - avatar
2 Respostas
+ 28
To set data: window.localStorage.setItem(key, value); To get data: window.localStorage.getItem(key) To remove data: window.localStorage.removeItem(key); To clear all: window.localStorage.clear(); To get the length of all the data (keys): window.localStorage.length To get a key at position `n`: window.localStorage.keys(n) You can use .getItem and .keys to get the first item in the localStorage, like this: var data = window.localStorage.getItem(window.localStorage.keys(0));
5th Mar 2019, 8:54 AM
Rowsej
Rowsej - avatar
5th Mar 2019, 12:45 PM
Ore
Ore - avatar