Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js clear local storage

localStorage.clear();//WARNING!: This will clear all your local storage
Comment

how to clear local storage

localStorage.clear();
Comment

js localstorage clear

<!DOCTYPE html>
<html>
  <head>
    <style>
      body {
        text-align: center;
      }
      h1 {
        color: green;
      }
    </style>
  </head>
  <body>
    <h2>Create local storage items </h2>
    <button onclick="createItems()">
      Create local storage items
    </button>
    <h2>Display Items</h2>
    <button onclick="displayItems()"> Display items</button>
    <p id="show"></p>
    <h2>Remove Items</h2>
    <button onclick="deleteItems()"> Clear locak storage </button>
    <h2>Display Items Again</h2>
    <button onclick="displayItems()"> Display again </button>
    <p id="demo"></p>
    <script>
      function createItems() {
        // Set item in local storage. 
        localStorage.setItem("Welcome toW3Docs ", " ");
        localStorage.setItem("Storage Clear Method ", " ");
      }
      function deleteItems() {
        // Clear localStorage items 
        localStorage.clear();
      }
      function displayItems() {
        let l, i;
        // Display items 
        document.getElementById("show").innerHTML = "";
        for(i = 0; i < localStorage.length; i++) {
          res = localStorage.key(i);
          document.getElementById("show").innerHTML += res;
        }
      }
    </script>
  </body>
</html>
Comment

js localstorage clear

<!DOCTYPE html>
<html>
  <head>
    <style>
      body {
        text-align: center;
      }
      h1 {
        color: green;
      }
    </style>
  </head>
  <body>
    <h2>Create local storage items </h2>
    <button onclick="createItems()">
      Create local storage items
    </button>
    <h2>Display Items</h2>
    <button onclick="displayItems()"> Display items</button>
    <p id="show"></p>
    <h2>Remove Items</h2>
    <button onclick="deleteItems()"> Clear locak storage </button>
    <h2>Display Items Again</h2>
    <button onclick="displayItems()"> Display again </button>
    <p id="demo"></p>
    <script>
      function createItems() {
        // Set item in local storage. 
        localStorage.setItem("Welcome toW3Docs ", " ");
        localStorage.setItem("Storage Clear Method ", " ");
      }
      function deleteItems() {
        // Clear localStorage items 
        localStorage.clear();
      }
      function displayItems() {
        let l, i;
        // Display items 
        document.getElementById("show").innerHTML = "";
        for(i = 0; i < localStorage.length; i++) {
          res = localStorage.key(i);
          document.getElementById("show").innerHTML += res;
        }
      }
    </script>
  </body>
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: if checkbox is checked open modal popup 
Javascript :: how get value of json encode in laravel 
Javascript :: get document jquery 
Javascript :: set focus on load javascript 
Javascript :: how to change text to italic in javascript 
Javascript :: if input value is null do something 
Javascript :: javascript create an array of range between two numbers 
Javascript :: javascript remove duplicated from Array 
Javascript :: jquery textarea autosize 
Javascript :: relaod the page in express 
Javascript :: how-to-save-array in Local storage - js 
Javascript :: how to import your external js 
Javascript :: how to get the max value of two variables in math 
Javascript :: how to get the url of a page in javascript 
Javascript :: how to validate a string using regular expression in javascript 
Javascript :: daysinmonth javascript 
Javascript :: write own nodemon in package.json 
Javascript :: linear gradient reactjs 
Javascript :: default input type date limit date js 
Javascript :: javascript find 
Javascript :: javascript join 
Javascript :: react disable eslint errors 
Javascript :: How to fix WordPress jQuery is not defined 
Javascript :: phone patter regex 
Javascript :: javascript get intersection of two arrays 
Javascript :: how to use hidden in div in angular 
Javascript :: lodash convert object to array 
Javascript :: electron open new window 
Javascript :: File type node js 
Javascript :: javascript custom repeat function 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =