Local Storage
How do I make an local storage?
What is a local storage? How do you make a local storage? This script and codes were developed by Dang Van Thanh on 13 September 2022, Tuesday.
Local Storage - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Local Storage</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="form"> <p> <input type="text" id="fullname" placeholder="Fullname"/> <input type="text" id="address" placeholder="Address"/> </p> <p> <button id="save">Save</button> <button id="load">Load</button> </p> <p> <button id="clear">Clear</button> <button id="reset">Reset</button> </p>
</div> <script src="js/index.js"></script>
</body>
</html>
Local Storage - Script Codes CSS Codes
.form { margin: 20px;
}
.form input[type="text"] { border: 1px solid #c4c4c4; padding: 5px 10px;
}
.form button { background-color: #214cce; border: 0; border: 1px solid #919191; color: #fff; padding: 7px 15px; width: 80px; cursor: pointer;
}
.form button:hover, .form button:focus { background-color: #0c1b4a;
}
Local Storage - Script Codes JS Codes
var fullname = document.getElementById('fullname'), address = document.getElementById('address'), saveButton = document.getElementById('save'), loadButton = document.getElementById('load'), clearButton = document.getElementById('clear'), resetButton = document.getElementById('reset');
var localStore = { saveLocalStorage: function() { localStorage.setItem('item', JSON.stringify(this.getInputValue())); }, loadLocalStorage: function() { var store = JSON.parse(localStorage.getItem('item')); if ( store ) { fullname.value = store.fullname; address.value = store.address; } }, clearLocalStorage: function() { localStorage.removeItem('item'); }, getInputValue: function() { return { fullname: fullname.value, address: address.value } }
};
saveButton.addEventListener('click', function() { localStore.saveLocalStorage();
}, false);
loadButton.addEventListener('click', function() { localStore.loadLocalStorage();
}, false);
clearButton.addEventListener('click', function() { localStore.clearLocalStorage();
}, false);
resetButton.addEventListener('click', function() { fullname.value = ''; address.value = '';
}, false);
Developer | Dang Van Thanh |
Username | dangvanthanh |
Uploaded | September 13, 2022 |
Rating | 3 |
Size | 2,458 Kb |
Views | 24,288 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Simple Carousel Pure CSS | 4,080 Kb |
Pure CSS Off Canvas Icon | 1,944 Kb |
Browser Pure CSS3 | 2,439 Kb |
Rotate in CSS3 3D Transform | 1,631 Kb |
Simple Navigation and Transition | 2,313 Kb |
Modal Bootstrap with ReactJS | 2,716 Kb |
Rotate in CSS3 Transform | 2,013 Kb |
Checkboxes jQuery Plugin | 2,405 Kb |
Tooltips using CSS Triangles Mixin | 2,258 Kb |
CSS3 Multi-Column Module 1 | 2,212 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Base-Style | Daniel_gooss | 2,614 Kb |
CSS Infinite 360 | APinix | 5,564 Kb |
Two Element Typeface | Chrisota | 4,942 Kb |
Hoi hoi | JohnTheCat | 7,248 Kb |
Import shader in three.js | Khangeldy | 2,636 Kb |
Learning FlexBox | Alex_rodrigues | 2,821 Kb |
A Pen by Taylor Vowell | Taylorvowell | 5,962 Kb |
Flying Bee | Pwsm50 | 3,711 Kb |
A Pen by Andrea Verlicchi | Verlok | 2,018 Kb |
SVG Animation | Pollardld | 3,133 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!