<script>
document.getElementById("display").innerHTML = localStorage.getItem("notes");
function noteIt() {
localStorage.setItem("notes", localStorage.getItem("notes") + document.getElementById("txt").value + "<br>");
document.getElementById("display").innerHTML = localStorage.getItem("notes");
}
function reset() {
localStorage.setItem("notes", "")
document.getElementById("display").innerHTML = localStorage.getItem("notes");
}
</script>
<textarea id="txt"></textarea><br>
<button onClick="noteIt()">Note It!</button>
<button onClick="reset()">Reset!</button><br>
<p id="display"></p>
With this code, the problem is when I have data in the variable, "notes" when I reload the webpage the line at the top of the js won't run. If I typed in, "Hi" to the textarea and pressed "Note it!", when I reload the browser I do not see the text, "Hi" appear on my screen.
Could someone please help me? Thank you in advance!