开发者

Can not figure out how to delete local storage

开发者 https://www.devze.com 2023-03-20 11:10 出处:网络
I tried making a reset button to delete everything but when you refresh page the list reappears...Any ideas?

I tried making a reset button to delete everything but when you refresh page the list reappears...Any ideas?

http://jsfiddle.net/y8Uju/12/

EDITL: Sorry, you are right, stupid me I forgot to change my storage's name...duh..haha...thanks a lot! I am not very familiar with html 5, still learning it.

    var saved = JSON.parse(localStor开发者_如何学编程age["numbers"] || "[]");
for(var i = 0; i < saved.length; i++) {
    storage.removeItem('saved[i]');
    add(false);
}


localStorage has two ways to remove data:

storage.removeItem('key'); // remove one item
storage.clear();           // remove everything
0

精彩评论

暂无评论...
验证码 换一张
取 消