Reputation: 3735
This is some weird error:
localStorage.removeItem("myKey");
var temp = localStorage.getItem("myKey");
// temp = undefined
But, if I ctrl-F5 and do this:
var temp = localStorage.getItem("myKey");
console.log(temp);
Then all data is still there! How can I completely remove it?
Upvotes: 0
Views: 678
Reputation: 9000
To remove all localStorage data, do it with:
localStorage.clear()
Fiddle example: http://jsfiddle.net/f5w3p/
Now... to remove only specific Item
and not all the data.. just with removeItem
localStorage.removeItem('test')
Fiddle example: http://jsfiddle.net/f5w3p/1/
...
If after Ctrl+F5 you still get some or even same data as before...
...then you must be setting up that data again before you actually read it.
Give us a full working fiddle example and for sure, someone find's out where your problem is.
Upvotes: 3