+ 1
Local Storage, how to remove item? Please help
Hey coders, I've been brainstorming a lot to do a simple goal tracker app using local storage. I'm able to add items in the list but, I'm not getting it how to remove items from the list. Could you help please ? Also, this code for adding items works in my live server VS code, but not in solo learn or even code pen :( https://code.sololearn.com/Wa22A206a16A
3 ответов
+ 2
Renu
Simple
localStorage.removeItem(key)
0
Hi AJ,
I tried to do that. Wells, I'm able to remove that item from console, but it's not updating on my app :(
0
Firs,t in HTML you need to add a closing body tag, this why your code doesn't run on sololearn
Second, I suggest using for/in instead of the original for loop, this will give you direct access to the key.
for(key in localstorage){
localstorage.removeItem(key)
}
You should also be aware that you will not have access to localstorage when using sololean android app.