-2

I am making a file where you type a "post" and it shows it. How can I make that "post" save so next time I open the file on Chrome it still shows the variable text?

<h3 style="color:teal;padding:8">My Post</h3>
<p id="post" style="padding:8"></p>
<button id="myButton" onclick="var post=prompt('What would you like to say?');document.getElementById('post').innerHTML = post;">Edit!</button>

1 Answers1

0

this work like just you want it

<h3 style="color:teal;padding:8">My Post</h3>
    <p id="post" style="padding:8"></p>
    <button id="myButton" onclick="var post=prompt('What would you like to say?');document.getElementById('post').innerHTML = post;localStorage.setItem("post", post);">Edit!</button>
    <script>
    document.getElementById('post').innerHTML = localStorage.getItem("post");
    </script>
Hemant Rajpoot
  • 683
  • 1
  • 11
  • 29