Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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.getElementById("entryTitle").value;
    var entryText = document.getElementById("entryText").value;
    var entry = {
        "title": entryTitle,
        "text": entryText
    };
    localStorage.setItem("entry", JSON.stringify(entry));
    // Save allEntries back to local storage
    existingEntries.push(entry);
    localStorage.setItem("allEntries", JSON.stringify(existingEntries));
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: Remove line breaks with JavaScript 
Javascript :: giving height full in next image 
Javascript :: load node by id drupal 8 
Javascript :: just number regex js 
Javascript :: base64 encode node js 
Javascript :: select element by id js 
Javascript :: adding a button in javascript 
Javascript :: js redirect to relative url 
Javascript :: socket io with cors 
Javascript :: js arrondir a deux decimal 
Javascript :: change id in jquery 
Javascript :: how to remove backslash from string in javascript 
Javascript :: disable console log alert eslint 
Javascript :: angular pipe capitalize 
Javascript :: javascript angle equation of a line 
Javascript :: sort array of object js 
Javascript :: Hide a div on clicking outside it with jquery 
Javascript :: convert english number to bangla javascript 
Javascript :: javascript isset 
Javascript :: seconds to hh mm ss javascript 
Javascript :: generate random number javascript 
Javascript :: jquery video play 
Javascript :: angular for loop key value 
Javascript :: tolowercase javascript 
Javascript :: array of A-Z 
Javascript :: e vs backwards e math 
Javascript :: how to play jquery audio 
Javascript :: javascript get all array elements except last 
Javascript :: validador de cep javascript 
Javascript :: jquery ajax post form 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =