-4

The code below saves the contents of a <textarea> to the DOM when the Save button is clicked.

function save() {
    // Create the new element
    const newElement = document.createElement("p");
    const txt = document.createTextNode(document.getElementById("editorBox").value);
    newElement.appendChild(txt);
    // Add the new element to the DOM
    const insertionPoint = document.getElementById("insertionPoint");
    insertionPoint.appendChild(newElement);
}

However, the changes are not added to the HTML file and, therefore, are removed as soon as the page is refreshed. Is there a way to make persistent/permanent changes to the HTML file? How?

WillyB
  • 15
  • 3
  • Yeah, without a server `localStorage` – zer00ne May 13 '22 at 22:26
  • No, you cannot do this without using server-side code, e.g. asp.net, php, etc. Or, you can fake it by storing "changes" in localStorage and then retrieving this in javacript – Lee Taylor May 13 '22 at 22:26

0 Answers0