HTML DOM Datalist Object Last Updated : 14 Jun, 2023 Comments Improve Suggest changes Like Article Like Report The DOM Datalist Object is used to represent the HTML <Datalist> element. The Datalist element is accessed by getElementById(). Properties: It has an 'Option' attribute which is used to return the collection of all options values in a datalist. Syntax: document.getElementById("gfg"); Where "gfg" is the ID assigned to the "Datalist" Tag. Collections: options: It is used to return the number of options in an <datalist> element. Example 1: In this example, we will use DOM Datalist Object HTML <!DOCTYPE html> <html> <body> <h1 style="color:green;font-size:39px;"> GeeksForGeeks </h1> <h2>DOM Datalist object</h2> <form> <label>Your Cars Name: </label> <input list="gfg"> <datalist id="gfg"> <option value="BMW" > <option value="Bentley" > <option value="Mercedes" > <option value="Audi" > <option value="Volkswagen" > </datalist> </form> <br> <button onclick="myGeeks()">Submit</button> <p id="sudo"></p> <script> function myGeeks() { let g = document.getElementById("gfg").options.length; document.getElementById("sudo").innerHTML = "There are " + g + " options in the list."; } </script> </body> </html> Output: Example 2: In this example, we will HTML DOM Datalist Object. HTML <!DOCTYPE html> <html> <body> <h1 style="color:green;font-size:39px;"> GeeksForGeeks </h1> <h2>DOM Datalist object</h2> <form id="GFG"> <b><label>Your cars name:</label></b> </form> <br> <button onclick="myGeeks()">Submit</button> <script> function myGeeks() { let g = document.createElement("INPUT"); g.setAttribute("list", "cars"); document.getElementById("GFG").appendChild(g); let f = document.createElement("DATALIST"); f.setAttribute("id", "cars"); document.getElementById("GFG").appendChild(f); let w = document.createElement("OPTION"); w.setAttribute("value", "BMW"); document.getElementById("cars").appendChild(w); let x = document.createElement("OPTION"); x.setAttribute("value", "Mercedes"); document.getElementById("cars").appendChild(x); } </script> </body> </html> Output: Supported Browsers: The browser supported by DOM Datalist Object are listed below: Google ChromeInternet ExplorerFirefoxOperaSafari Comment More infoAdvertise with us M manaschhabra2 Follow Improve Article Tags : Misc Web Technologies HTML Web technologies HTML-DOM +1 More Practice Tags : Misc Similar Reads HTML DOM Style animationIterationCount Property The Style animationIterationCount property in HTML DOM is used to set or return how many times an animation should be played. Syntax: It is used to return the animationIterationCount property.object.style.animationIterationCountIt is used to set the animationIterationCount property.object.style.anim 2 min read HTML DOM WheelEvent deltaX Property The WheelEvent.deltaX property in HTML is used to return a positive double value when the web page is scrolled horizontally along the left or right direction. If the page is scrolled to the right it returns a positive value, and a negative double value when scrolled to the left, else it returns zero 1 min read HTML DOM offsetHeight Property The DOM offsetHeight property is used to return the layout height of an element as an integer. It is measured in pixels. It includes height, border, padding, and horizontal scrollbars but not margin. If the element is hidden then it returns 0. Syntax: element.offsetHeight Return Value: It returns th 2 min read HTML DOM Style borderColor Property The DOM Style borderColor property specifies the color of the element's border. It may be given explicitly, inherit from the parent or by default it will take the default value. Syntax: To get the border color property:object.style.borderColorTo set the border color property:object.style.borderColor 3 min read HTML DOM Style borderBottomStyle Property The style borderBottomStyle property in HTML DOM is used to set or return the style of the bottom border of an element. Syntax: It returns the style of the bottom border.object.style.borderBottomStyleIt sets the style of the bottom border.border-bottom-style: value; Property Values: none: It is the 2 min read HTML DOM Del Object The Del Object in HTML DOM is used to represent the HTML <del> element. The <del> element can be accessed by getElementById(). Object Properties: cite: It is used to set or return the value of the cite attribute of a deleted element.dateTime: It is used to sets or return the value of the 2 min read HTML DOM removeAttribute() Method The DOM removeAttribute() method is used to remove an attribute with specified name from the element. It is similar to the removeAttributeNode() method but the difference is that the removeAttributeNode method is used to remove the specified attribute object, but on the other hand, removeAttribute r 1 min read HTML DOM DD Object The DOM DD Object is used to represent the HTML <DD> element. The DD element is accessed by getElementById(). Syntax: document.getElementById("ID"); Where âidâ is the ID assigned to the âddâ tag. Example 1: In this example, we will use DOM DD Object. HTML <!DOCTYPE html> <html> 2 min read HTML DOM Style backgroundClip Property The DOM style backgroundClip Property is used to set or return the painting area of the background. Syntax: It is used to return the backgroundClip property.object.style.backgroundClip It is used to set the backgroundClip property. object.style.backgroundClip = "border-box|padding-box|content-box|in 1 min read HTML DOM setAttributeNode() Method The setAttributeNode() method in HTML DOM is used to add the specified attribute node to an element. If the specified attribute is already present, then this method replaces it. Syntax: element.setAttributeNode(name) Parameter: Only one parameter is accepted name.Where the name is the attribute node 1 min read Like