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();
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();
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
save to local storage
localStorage.setItem('myCat', 'Tom');
var cat = localStorage.getItem('myCat');
localStorage.removeItem('myCat');
// Clear all items
localStorage.clear();
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();
}
local storage javascript
localStorage.setItem('user_name', 'Rohit'); //store a key/value
var retrievedUsername = localStorage.getItem('user_name'); //retrieve the key
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>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us