HTML | DOM Storage setItem() Method Last Updated : 14 Jul, 2022 Comments Improve Suggest changes Like Article Like Report The setItem() method is used to set the storage object item which is specified by the user. This storage object can be a localStorage object or sessionStorage object. Syntax: For local storage: localStorage.setItem(keyname, value) For session storage: sessionStorage.setItem(keyname, value) Parameters: Two parameters are required :- Keyname: It specifies the name of the key used for getting the value.value: It specifies the value which replaces the old value. Return Value: A String, representing the inserted value. Example: html <!DOCTYPE html> <html> <head> <!--script for creating new local storage item and retrieve it --> <script> // Set item in local storage. function createItem() { localStorage.setItem("city", "Gwalior"); } function myFunction() { var x = localStorage.getItem("city"); document.getElementById("demo").innerHTML = x; } </script> </head> <body> <h1>Welcome to GeeksforGeeks</h1> <h3>The Storage setItem() Method</h3> <p>Click on button to create a local storage item </p> <button onclick="createItem()"> Create local storage item </button> <p>Click the button to get the item value:</p> <button onclick="myFunction()"> Get the item value </button> <p id="demo"></p> </body> </html> Output: Before: After: Supported Browsers: The browser supported by DOM setItem() Method are listed below: Google Chrome 4 and aboveEdge 12 and aboveInternet Explorer 8 and aboveFirefox 3.5 and aboveOpera 10.5 and aboveSafari 4 and above Comment More infoAdvertise with us P ProgrammerAnvesh Follow Improve Article Tags : Web Technologies HTML HTML-DOM HTML-Methods Similar Reads HTML | DOM Ol reversed Property The DOM Ol reversed Property is used to set or return whether the list items are in Descending order(9, 8, 7, 6, ...) or in Ascending order(1, 2, 3, 4...). Syntax: It is used to return the reversed property.olObject.reversedIt is used to set the reversed property.olObject.reversed = true|false Prope 2 min read HTML | DOM Ol type Property The DOM Ol type Property is used to set or return the type attribute in an ordered list. This attribute defines which type(1, A, a, I and i) of order you want in your list numeric, alphabetic or roman numbers. Syntax: It is used to return the type property. olObject.type It is used to set the type p 2 min read HTML | DOM Form enctype Property The Form enctype property in HTML DOM is used to set or return the value of the enctype attribute in a form. This attribute specifies the data that will be present in the form should be encoded when submitting to the server. This type of attribute can be used only if method = "POST". Syntax: It is u 3 min read HTML DOM Form reset() Method The reset() method in the HTML DOM is used to reset a form fields to their default values. When a form is reset, all user input is cleared, and the fields revert to their initial states.SyntaxformObject.reset()Example: In this example, clicking the reset button clears the form inputs. html<!DOCTY 1 min read HTML | DOM Form submit() Method The form submit() Method in HTML DOM is used to send the form data to the web-server. It works as same as submit button. It does not contain any parameters. Syntax: formObject.submit()Example: index.html<!DOCTYPE html> <html> <head> <title> HTML DOM Form submit() Method </ 1 min read HTML | DOM Location Search Property The Location Search property in HTML DOM is used to set or return the query part of URL including question mark. The query part is the part of URL after the question mark. Syntax: It returns the location search property.location.searchIt is used to set the location search property.location.search = 1 min read HTML DOM Form action Property The HTML DOM Form action property allows accessing and modifying the action attribute of a form element through JavaScript. It determines the URL where form data is submitted when the form is submitted. Syntax: It is used to return the action property. formObject.actionIt is used to set the action p 3 min read HTML | DOM Form autocomplete Property The Form autocomplete property in HTML DOM is used to set or return of the autocomplete attribute. The autocomplete attribute is used to specify whether the autocomplete attribute has "on" or "off" value. When the autocomplete attribute is set to on so the browser will automatically complete the val 2 min read HTML | DOM Textarea rows Property The DOM Textarea rows Property is used to set or return the value of a rows attribute of a textarea field. The rows attribute specifies the number of visible text lines for the control i.e the number of rows to display. Syntax: It is used to Return the rows property:textareaObject.rowsIt is used to 2 min read HTML DOM Video Object The Video object in HTML DOM represents an <video> element. The video element can be accessed by using getElementById() method. Syntax: To access a video object: document.getElementById("videoId");where id is assigned to the <video> tag.To create a video object: document.createElement("V 4 min read Like