Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Local Storage

<script>
  //an immediately invoked function that checks to see if the text is in local storage already
  (function(){
    //if the text is in local storage, set the html
    if (localStorage.currentTotal){
    console.log(localStorage.currentTotal);
    document.getElementById('class').innerHTML = localStorage.getItem("currentTotal");
  }
    })();
  //function that gets called for an onclick event
  function myFunction() {
// Store in local storage
localStorage.setItem("currentTotal", "Class current balance total");
//set the inner html to what is in local storage
document.getElementById("class").innerHTML = localStorage.getItem("currentTotal");

}
</script>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Local #Storage
ADD COMMENT
Topic
Name
2+5 =