Storage.setItem()


ืคื•ื ืงืฆื™ื™ืชย ()setItem ืžืืคืฉืจืช ืœื”ื•ืกื™ืฃ ื ืชื•ื ื™ื ืืœ ื”ืื—ืกื•ืŸ ื”ืžืงื•ืžื™ ื‘ืืžืฆืขื•ืช ืฉื ื™ ืคืจืžื˜ืจื™ื: ืฉื ืžืคืชื—ย ื•ืขืจืš ืฉืื•ืชื ืชื™ืฆื•ืจ ืื• ืชืขื“ื›ืŸ ื‘ืžื™ื“ื” ื•ืงื™ื™ืžื™ื.

ืชื—ื‘ื™ืจ

storage.setItem(keyName, keyValue);

ืคืจืžื˜ืจื™ื

keyName
ืžื›ื™ืœ ืืช ืฉืžื• ืฉืœ ื”ืžืคืชื— ืื•ืชื• ื™ืฉ ืœื™ืฆื•ืจ ืื• ืœืขื“ื›ืŸ.
keyValue
ืžื›ื™ืœ ืืช ืฉื ื”ืขืจืš ืฉื™ืชื•ื•ืกืฃ ืœืžืคืชื— ืื•ืชื• ืื ื• ื™ื•ืฆืจื™ื ืื• ืžืขื“ื›ื ื™ื.

ืขืจืš ื—ื•ื–ืจ

undefined.

ื”ื—ืจื’ื•ืช

ื‘ืžื™ื“ื” ื•ื”ืื—ืกื•ืŸ ืžืœื ื”ืžืขืจื›ื•ืช ืขืฉื•ื™ื” ืœื ืงื•ืช ื ืชื•ื ื™ื ืžื”ืื—ืกื•ืŸ ื”ืžืงื•ืžื™.
ื‘ื’ืจืกื” ื”ื ื™ื™ื“ืช ืฉืœ ื“ืคื“ืคืŸย Safari, ื‘ืžื™ื“ื” ื•ื”ืžืฉืชืžืฉ ื ื›ื ืก ืืœ ืžืฆื‘ ืคืจื˜ื™ ื”ืžืขืจื›ืช ืื™ื ื” ืฉื•ืžืจืช ื ืชื•ื ื™ื ื‘ืื—ืกื•ืŸ ื”ืžืงื•ืžื™ ื•ืžืกื™ืจื” ืื•ืชื ื‘ืื•ืคืŸ ืื•ื˜ื•ืžื˜ื™ ื‘ืฉืœ ืžื’ื‘ืœืช ื’ื•ื“ืœ ืฉืœ 0 ื‘ืชื™ื.

ื“ื•ื’ืžืื•ืช

ื”ืคื•ื ืงืฆื™ื” ื”ื‘ืื” ื™ื•ืฆืจืช ืฉืœื•ืฉื” ืคืจื™ื˜ื™ ื ืชื•ื ื™ื ื‘ืชื•ืš ื”ืื—ืกื•ืŸ ื”ืžืงื•ืžื™.

function populateStorage() {
  localStorage.setItem('bgcolor', 'red');
  localStorage.setItem('font', 'Helvetica');
  localStorage.setItem('image', 'myCat.png');
}

ืžืคืจื˜

Specification Status Comment
HTML Living Standard
The definition of 'Storage.setItem' in that specification.
Living Standard ย 

ืชืื™ืžื•ืช ื“ืคื“ืคืŸ

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
setItemChrome Full support 4Edge Full support 12Firefox Full support 3.5IE Full support 8Opera Full support 10.5Safari Full support 4WebView Android Full support YesChrome Android Full support 18Firefox Android Full support 6Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android ?

Legend

Full support ย 
Full support
Compatibility unknown ย 
Compatibility unknown

ืจืื• ื’ื