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

javascript local storage delete

localStorage.removeItem('name');
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 :: regExp for finding a first letter and last letter in a string 
Javascript :: empty the value of an input in jquery 
Javascript :: jetbrains mono 
Javascript :: query params in next js 
Javascript :: website link regex stackoverflow 
Javascript :: what is the difference beetween += and =+ 
Javascript :: ngx paypa remove credit card 
Javascript :: salut 
Javascript :: javascript get time ago with moment 
Javascript :: scroll to bottom of a div react 
Javascript :: check whether a checkbox is checked in jQuery 
Javascript :: load js file 
Javascript :: js compare lists 
Javascript :: next js tailwind 
Javascript :: datatable row color 
Javascript :: delete slash commands discord.js 
Javascript :: js distance from top 
Javascript :: angular module with routing cli 
Javascript :: how to add keyframe in emotion stled 
Javascript :: lodash delete object property 
Javascript :: datalist example 
Javascript :: how can auto download window print in javascript 
Javascript :: detect mobile device 
Javascript :: convert base64 to uint8array javascript 
Javascript :: javascript create matrix 
Javascript :: node.js socket.io send data with handshake 
Javascript :: cypress scroll bottom 
Javascript :: convert the following 2 d array into 1 d array in javascript 
Javascript :: string to char array in javascript 
Javascript :: convert negative number to positive in javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =