You didn't exactly say what the problem is... but I do see a number of issues with the code.
var textareaElement = document.querySelector("textarea");
This selects the first textarea on the page. What if there's another? It'd be better to give it a unique id or class name so that you are sure that you are selecting the desired textarea element.
textareaElement.addEventListener("onblur", saveEntry);
The comment says to listen to the
change event, not the
blur event. Also, do not include the "on" prefix when naming events.
text = textareaElement.value;
This relies upon a global variable outside of the event listener. This is an extremely poor practice. The
target of the event is available in the
event construct as
target; use that.
var data = text;
Why?
localStorage.setItem(key, item);
What's
key? Where does it come from?
console.log("saved item", key, "=", textareaElement.value);
This doesn't prove anything. Fetch the value from local storage to ensure that it's been set.