N
N
Nikita Shchypylov2016-09-17 12:48:35
JavaScript
Nikita Shchypylov, 2016-09-17 12:48:35

Why does the localStorage value disappear when the page is refreshed?

Hello everyone
Inspired by the advice of one lion ( DevMan, hello, if you are reading), I decided to make a competitor to Evernote using localStorage, but there is a problem.
I have this funk to save value from input:

function saveValue() {
  save_button.addEventListener('click', function (e) {
    e.preventDefault();
    var input = document.getElementById('note_' + count);
    var placeHolder = document.getElementById('text');
    localStorage.setItem("note_number_" + count, input.value);
    var hello = localStorage.getItem("note_number_" + count);
    return placeHolder.innerHTML = hello;
  })
}

Here is the value that appears on the page: click-clack
But when the page is refreshed, the value will disappear. The value remains in the console. What's the magic?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SagePtr, 2016-09-17
@Nikulio

This is the code for writing the value, but show more code for reading. And where does the count variable come from?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question