Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript localStorage clear items

localStorage.clear();//this clears the localStorage completely
Comment

js clear local storage

localStorage.clear();//WARNING!: This will clear all your local storage
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 :: split sentence including special characters javascript 
Javascript :: resolveJsonModule 
Javascript :: remove hidden attribute in js 
Javascript :: javascript scroll to bottom 
Javascript :: javascript get text between two words 
Javascript :: Masonry js cdn 
Javascript :: http request in js 
Javascript :: react get screen width 
Javascript :: add attribute selected jquery 
Javascript :: get array of all property in object array 
Javascript :: set delay react native 
Javascript :: js convert nodelist to array 
Javascript :: generate random boolean javascript 
Javascript :: how to run angular 
Javascript :: ffmpeg/avconv not found 
Javascript :: javascript change color for class name 
Javascript :: redirect is not defined react/jsx-no-undef 
Javascript :: scroll to javascript 
Javascript :: React + modal: input field auto focus 
Javascript :: javascript detect collision 
Javascript :: setup ejs views directory in express 
Javascript :: how to update node js version 
Javascript :: js get number from string 
Javascript :: javascript includes case insensitive 
Javascript :: js how to check typeof boolean 
Javascript :: refresh page on back button click javascript 
Javascript :: jquery set style background image 
Javascript :: mui theme remove shadow 
Javascript :: javascript get if IE11 
Javascript :: javascript HOW set delay 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =