How do I save the current page data in html, css , javascript?

Viewed 33

Am trying to save the button the user creates, when the browser is refreshed.Meaning I want it to permanently stay there.

Here is a snippet of what am taking about:

function create(){
  const a =  document.createElement("button")
  document.body.appendChild(a)
   const b = document.getElementById("buttoname")
   a.innerHTML = b.value
}
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<h1>Create a button</h1>
Button name:<input id="buttoname" type="text"><br>

<button onclick="create()">Create Button</button>

</body>

   
</html>
Thank for your help it means a lot.

1 Answers

Check out localStorage - docs, you can save a variable there with the information for each created button. Then you need a function that will read the localStorage when the page loads and will create the described buttons

Related