I need to save contents of a html div (id=tabela) to localstorage, so that the contents of the table can be loaded in another session via localstorage. How to get the div contents into a variable?
var = tabelaContent; //<-- I need contents of <div id=tabela> in this
localStorage.setItem("tabelaContent",tabelaContent);
// then, upon pressing the "load" button
localStorage.getItem(tabelaContent);
FYI if there is another way of making the table's content persistent, let me know
TIA.
You can use document.getElementById("myID").innerHTML
, like this:
var = tabelaContent;
tabelaContent = document.getElementById("tabela").innerHTML
localStorage.setItem("tabelaContent",tabelaContent);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With