Answers for "how to save to local Storage"

2

js save local storage

//Set item
localStorage.setItem('myCat', 'Tom');
//Get item
var cat = localStorage.getItem("myCat");
//Remove item
localStorage.removeItem("lastname");
//Remove all items
localStorage.clear();
Posted by: Guest on May-08-2021
26

javascript store object in local storage

var person = { "name": "billy", "age": 23};

localStorage.setItem('person', JSON.stringify(person)); //stringify object and store
var retrievedPerson = JSON.parse(localStorage.getItem('person')); //retrieve the object
Posted by: Guest on July-22-2019
5

save to local storage

localStorage.setItem('myCat', 'Tom');

var cat = localStorage.getItem('myCat');

localStorage.removeItem('myCat');

// Clear all items
localStorage.clear();
Posted by: Guest on April-27-2020
6

local storage

function setItem(name, value) {
  localStorage.setItem(name, value);
}
function getItem(name) {
  localStorage.getItem(name);
}
function deletItem(name) {
  localStorage.removeItem(name);
}
function clearStorage() {
  localStorage.clear();
}
Posted by: Guest on October-26-2020
42

local storage javascript

localStorage.setItem('user_name', 'Rohit'); //store a key/value
var retrievedUsername = localStorage.getItem('user_name'); //retrieve the key
Posted by: Guest on October-23-2019
0

how to save to local Storage

<!DOCTYPE html>
<html>
 <head>
   <title>javascript</title>
 </head>
 <body>
   <input id="textbox" type="text" /><br><br>
   <button id="btn">Save</button>
   <br><br>
<script type="text/javascript">
var textbox = document.getElementById("textbox");
var button = document.getElementById("btn");

button.addEventListener("click", function(){
  localStorage.name = textbox.value;
});
document.write(localStorage.name);

</script>
 </body>
</html>
Posted by: Guest on June-28-2021

Code answers related to "how to save to local Storage"

Code answers related to "Javascript"

Browse Popular Code Answers by Language