local storage

- 약 5~10mb정도

- 웹 브라우저의 응용프로그램 저장소 > 로컬 저장소에서 확인

- 어플리케이션 종료 후 다시 켜도 저장했던 값을 불러올 수 있다(브라우저 마다)

- key, value 형태로 스토리지에 저장되고, 불러올 수 있다

- 사용자가 삭제하기 전까지는 데이터가 영구적으로 저장되어 있다

 

 

local-storage.js

$(function(){
	var storage=localStorage//로컬스토리지 객체 생성
    var name=document.getElementById("name")
    var cnt=document.getElementById("cnt")
    var size=document.getElementById("size")
    
  $('#save').click(function(){//저장
  	var item={
    	name:name.value,
        cnt:cnt.value
        size:size.value
    }
    storage.setItem(name.value,JSON.stringify(item))
  }
  
  $('#remove').click(function(){//삭제
  	storage.removeItem(name.value)
  }
}

 

 

'JavaScript' 카테고리의 다른 글

[JavaScript] prototype 기반 언어  (0) 2021.03.06

+ Recent posts