+ 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")â
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
+ 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.
0
I am using web.
what do you mean?
0
Your supposed to use javascript?
0
NVM I understant now
0
Understand