Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
141
rated 0 times [  144] [ 3]  / answers: 1 / hits: 24821  / 13 Years ago, thu, september 29, 2011, 12:00:00

I have 2 apps working together with localstorage and I was wondering how can I delete all the keys which start with note- and todo- . I know localstorage.clear() clears everything but thats not my aim.



Here is an example of what I have in my localstorage: enter



Where I want to delete all the todo-* with a button click and all note-* with other button click using jquery.



Thanks alot


More From » jquery

 Answers
1
Object.keys(localStorage)
.forEach(function(key){
if (/^todo-|^note-/.test(key)) {
localStorage.removeItem(key);
}
});

[#89870] Tuesday, September 27, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
larrycodys

Total Points: 394
Total Questions: 93
Total Answers: 78

Location: Romania
Member since Mon, Jun 6, 2022
2 Years ago
;