+ 1

LocalStorage

Why won’t it work <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> localStorage.setItem("name","ksl") </body> </html> It will just print “localStorage.setItem("name","ksl")”

16th Aug 2022, 9:34 AM
Uchennaya Obo Ibom
Uchennaya Obo Ibom - avatar
7 RĂ©ponses
+ 3
Dan and Dave localStorage is a part of JavaScript So you should set and get item inside script tag or use external JS. //Set item localStorage.setItem('xyz', 'abc'); //Get value var val = localStorage.getItem('xyz'); //Print value. console.log(val); // it will print abc
16th Aug 2022, 10:08 AM
AÍąJ
AÍąJ - avatar
+ 2
Dan and Dave It will not work in Sololearn. Try on Web. setItem is used to set data getItem is used to get data. console.log is used to print data.
16th Aug 2022, 9:35 AM
AÍąJ
AÍąJ - avatar
0
I am using web. what do you mean?
16th Aug 2022, 9:38 AM
Uchennaya Obo Ibom
Uchennaya Obo Ibom - avatar
0
Your supposed to use javascript?
16th Aug 2022, 9:39 AM
Uchennaya Obo Ibom
Uchennaya Obo Ibom - avatar
0
NVM I understant now
16th Aug 2022, 9:43 AM
Uchennaya Obo Ibom
Uchennaya Obo Ibom - avatar
0
Understand
16th Aug 2022, 9:43 AM
Uchennaya Obo Ibom
Uchennaya Obo Ibom - avatar