Вопрос

I am making little ToDo List using HTML5 local storage.
I want to show user a tiny notice that says 'SAVED!', when finished saving data in their local storage.

localStorage.setItem('todoList', data to save);

I dont know if its right way but can i just simply put whatever after setItem method?
something like:

localStorage.setItem('todoList', data to save); 
alert('saved!');

any help please.

Это было полезно?

Решение

Of course, you can. Here is an example of the code I used in a To-do app just like you:

try {
    localStorage.setItem("memo_list", JSON.stringify(list));
    alert('The memo is successfully saved.');
} catch (e) {
    alert('Error saving to storage.');
    throw e;
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top