What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-11-13 07:29:11
save text of div to localStorage, update localStorage when text is changed
// get the text var text = $('#test').text(); // set the item in localStorage localStorage.setItem('test', text); // bind text to 'blur' event for div $('#test').on('blur', function() { // check the new text var newText = $(this).text(); /... Add solution -
Javascript 2021-11-12 12:36:14
local storage check max size
//run this in dev console to test how much local storage you have try { // Test up to 20 MB for (var i = 250; i <= 20000; i += 250) { localStorage.setItem('test', new Array((i * 1024) + 1).join('a')); } } catch (e) { localStorage.removeItem('test... Add solution -
Javascript 2021-11-08 20:46:14
localsstorage array append element
function addEntry() { // Parse any JSON previously stored in allEntries var existingEntries = JSON.parse(localStorage.getItem("allEntries")); if(existingEntries == null) existingEntries = []; var entryTitle = document.getElementB... Add solution -
TypeScript 2021-11-02 22:56:13
how push objects into a local stotage array
// Get the existing data var existing = localStorage.getItem('myFavoriteSandwich'); // If no existing data, create an array // Otherwise, convert the localStorage string to an array existing = existing ? existing.split(',') : []; // Add new data to loca... Add solution -
Javascript 2021-10-28 10:54:18
javascript save data to local storage
var testObject = { 'one': 1, 'two': 2, 'three': 3 }; // Put the object into storage localStorage.setItem('testObject', JSON.stringify(testObject)); // Retrieve the object from storage var retrievedObject = localStorage.getItem('testObject'); console.lo... Add solution -
Javascript 2021-10-27 23:27:14
Javascript store in localStorage
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 Add solution -
Javascript 2021-10-27 01:45:11
Storing Objects in HTML5 localStorage
var testObject = { 'one': 1, 'two': 2, 'three': 3 }; // Put the object into storage localStorage.setItem('testObject', JSON.stringify(testObject)); // Retrieve the object from storage var retrievedObject = localStorage.getItem('testObject'); console.lo... Add solution -
Javascript 2021-10-26 07:36:12
localstorage javascript array
//storing array in localStorage var colors = ["red","blue","green"]; localStorage.setItem("my_colors", JSON.stringify(colors)); //store colors var storedColors = JSON.parse(localStorage.getItem("my_colors&qu... Add solution -
Javascript 2021-10-24 14:38:07
json javascript
// Storing data: myObj = {name: "John", age: 31, city: "New York"}; myJSON = JSON.stringify(myObj); localStorage.setItem("testJSON", myJSON); // Retrieving data: text = localStorage.getItem("testJSON"); obj = JSON.... Add solution
Best helpers
Ranking is empty