Question

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.

Était-ce utile?

La solution

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;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top