Local Storage Là Gì? Xin Hãy Ngừng Dùng Local Storage


Create a localStorage name/value pair with name="lastname" and value="Smith", then retrieve the value of "lastname" & insert it into the element with id="result":

// StorelocalStorage.setItem("lastname", "Smith");// Retrieve document.getElementById("result").innerHTML = localStorage.getItem("lastname");

More "Try it Yourself" examples below.Bạn sẽ xem: How to get local storage in jquery

Definition và Usage

The localStorage & sessionStorage properties allow lớn save key/value pairs in a web browser.

Bạn đang xem: Local storage là gì? xin hãy ngừng dùng local storage

The localStorage object stores data with no expiration date. The data will not be deleted when the browser is closed, & will be available the next day, week, or year.

Tip: Also look at the sessionStorage property which stores data for one session (data is lost when the browser tab is closed).

Xem thêm: 4 Bước Mở Đại Lý Gạo Và Bí Quyết Số 1 00%, Muốn Mở Đại Lý Gạo Cần Bao Nhiêu Vốn

Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Property localStorage 4.0 8.0 3.5 4.0 11.5



Syntax for SAVING data to localStorage:

localStorage.setItem("key", "value");

Syntax for READING data from localStorage:

var lastname = localStorage.getItem("key");

Syntax for REMOVING data from localStorage:


Technical Details

Return Value: A Storage object

More Examples


The following example counts the number of times a user has clicked a button:

if (localStorage.clickcount) else document.getElementById("result").innerHTML = "You have clicked the button " + localStorage.clickcount + " time(s)."; Try it Yourself » ❮ Window Object màu sắc PICKER

like US

Get certifiedby completinga course today!

obatambeienwasirherbal.com.com CERTIFIED . 2021 Get started HOW khổng lồ Tabs Dropdowns Accordions Side Navigation vị trí cao nhất Navigation Modal Boxes Progress Bars Parallax Login khung HTML Includes Google Maps Range Sliders Tooltips Slideshow Sort danh sách Certificates HTML CSS JavaScript Front kết thúc Python SQL và more REPORT ERROR forums ABOUT cửa hàng ×

Report Error

If you want lớn report an error, or if you want khổng lồ make a suggestion, vị not hesitate khổng lồ send us an e-mail:



Thank You For Helping Us!

Your message has been sent to lớn obatambeienwasirherbal.com.com.