How to save data in local storage with javascript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

How to save data in local storage with javascript

local storage

24th Aug 2018, 10:11 AM
Chaim
Chaim - avatar
4 Answers
+ 2
Just googled this out, can try... function setPerson(){ var person = { 'name': getElementById('name'), 'photo': getElementById('photo')}; // Put the object into the storage alert(person); localStorage.setItem('person', JSON.stringify(person)); };
24th Aug 2018, 10:23 AM
Kojo Festus Dosu
Kojo Festus Dosu - avatar
+ 2
Here is a copy of a reply to a similar question recently. Hope it helps: Not sure if this will help but if you would like to look at an example you could check out my Recipe Box which uses local storage. See https://code.sololearn.com/W930yAQ9H12Q/#html.
24th Aug 2018, 10:51 AM
Richard Myatt
Richard Myatt - avatar
0
localStorage.setItem("name",item); to get stored item localStorage.getItem("name");
26th Aug 2018, 8:36 PM
Tech Inary
Tech Inary - avatar
0
It's best use id: localStorage.setItem('id', '{key: value, key2: value, ...}'); in SoloLearn don't work localSrorage.
29th Aug 2018, 2:31 AM
Mr Genesis
Mr Genesis - avatar