Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript storage get set item

// *** JS Storage Get/Set item *** 

	let target = document.getElementById("target");
    let increment = document.getElementById("increment");
    let count = localStorage.getItem("counter") || 0;
    target.innerHTML = count;

    increment.addEventListener("click", () => {
        count++;
        localStorage.setItem("counter", count);
        target.innerHTML = count;
    })
 
PREVIOUS NEXT
Tagged: #javascript #storage #set #item
ADD COMMENT
Topic
Name
5+4 =