Click on Edit> data entry> click on Save changes> refresh page. The result should be: the output on the page in the list of the data that I displayed before the page was declared. Here the sandbox podglyuchivaet. Apparently, does not work with localStorage. Link to codepen: https://codepen.io/alexseveneight/pen/rqvZjG

let out = document.getElementById('out'); let ul = document.createElement('ul'); out.appendChild(ul); for (let i = 0; i < 10; i++) { let li = document.createElement('li'); ul.appendChild(li); li.setAttribute('contentEditable', false); } let button = document.getElementById('button'); button.addEventListener('click', ()=> { setTimeout(function(){ let li = document.querySelectorAll('li'); for(let i=0; i < li.length; i++) { if(li[i].contentEditable === 'false'){ li[i].contentEditable = 'true'; button.innerHTML = 'Save changes'; } else { li[i].contentEditable = 'false'; button.innerHTML = 'Edit'; localStorage.setItem(li[i].innerHTML, li[i].innerHTML); localStorage.getItem(li[i].innerHTML, li[i].innerHTML); //localStorage.clear() } } },0); } ) 
 ul { height: 50px; //width: 250px; overflow: hidden; border: 1px solid #000; margin: 10px auto; padding-left: 0; list-style-type: none; display: flex; justify-content: flex-start; } li { background-color: gray; border: 1px dotted #000; width: calc(100%/10); height: 50px; line-height: 50px; color: white; text-align: center; } button { padding: 5px 20px; border: 1px dotted green; border-radius: 5px; background: #fff; } 
 <button id="button">Edit</button> <ul> <li>Customer</li> <li>Country FROM</li> <li>Postal code FROM</li> <li>Customs TO</li> <li>Delivery TO</li> <li>LDM - pallets</li> <li>Weight</li> <li>ADR</li> <li>Value of goods</li> <li>Price, EUR</li> </ul> <p id="out"></p> 

  • it is easier to write everything into 1 object and then serialize it and already store it in localStorage and from where to get this line is also equal to serialize Sasuke
  • No opportunity. Each time a new line is created with new data. There will be many objects in this case. Inconvenient. - Alex
  • one
    no problem. then save in this form [your line number 1] serialize the array into a string, save it to local, if a new line comes from local, do an array, add the string, and then save it to local again - Sasuke
  • a lot of action but all in 1 place - Sasuke
  • one
    that is, something will turn into a takeo JSON.stringify ([{name: 'awdwadawa', age: 34}, {name: 'awdwadawa', age: 34}]) result "[{" name ":" awdwadawa ", "age": 34}, {"name": "awdwadawa", "age": 34}] " - Sasuke

0