문제

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