Home > Software design >  Clear specific LocalStorage in HTML/JavaScript
Clear specific LocalStorage in HTML/JavaScript

Time:04-05

Is there any way to clear a specific localStorage in html using javascript:

localStorage.setItem("one");
localStorage.setItem("two");
//How to clear only "one"

CodePudding user response:

You can remove an item from the localStorage with the removeItem function:

localStorage.removeItem(key);

So in your case:

localStorage.removeItem("one");
  • Related