How to save textarea in HTML? [closed]

-5

When I run the javascript, it runs normally, my question was, how do I get the code now from that table that the script has changed.

    
asked by anonymous 13.11.2015 / 18:54

1 answer

3

Using HTML5 Local Storage you can save text from textarea locally, so even if you close the file the values will be there.

Code:

<!DOCTYPE html>
<html>
    <body>

    <html><table><textarea id='result'>Escreva aqui seu lembrete</textarea></table></html>
    <button onClick="salvar()">Salvar</button>

    <script>

    function salvar() {
        // Check browser support
        if (typeof(Storage) !== "undefined") {
            // Store
            localStorage.setItem("text", document.getElementById("result").value);

        } else {
            document.getElementById("result").innerHTML = "Local Storage não suportado";
        }
    }

    // Retrieve
        document.getElementById("result").innerHTML = localStorage.getItem("text");
    </script>

    </body>
</html>

JS Fiddle: link

    
13.11.2015 / 19:27