HTML | DOM Ul Object
The DOM Ul Object is used to represent the HTML <ul> element .the ul element is accessed by getElementById().
Properties:
Syntax:
document.getElementById("ID");
Where “id” is the ID assigned to the “ul” tag.
Example-1:
<!DOCTYPE html> <html> <head> <title>DOM ul Object</title> </head> <body> <h1>GeeksforGeeks</h1> <h2>DOM ul Object </h2> <ul id="Geeks"> <!-- Assigning id to 'li tag' --> <li id="GFG">Geeks</li> <li>Sudo</li> <li>Gfg</li> <li>Gate</li> <li>Placement</li> </ul> <button onclick="myGeeks()">Submit</button> <p id="sudo"></p> <script> function myGeeks() { // Accessing 'ul' tag. var g = document.getElementById( "Geeks").id; document.getElementById( "sudo").innerHTML = g; } </script> </body> </html> |
Output:
Before Clicking On Button :

After Clicking On Button :

Example-2 : <ul> Object can be created by using the document.createElement method.
<!DOCTYPE html> <html> <head> <title>DOM ul Object</title> </head> <body> <h1>GeeksforGeeks</h1> <h2>DOM ul Object </h2> <button onclick="myGeeks()">Submit</button> <script> function myGeeks() { // 'ul' tag Created. var g = document.createElement("UL"); g.setAttribute("id", "GFG"); document.body.appendChild(g); var f = document.createElement("LI"); var w = document.createTextNode("Geeks"); f.appendChild(w); document.getElementById("GFG").appendChild(f); var x = document.createElement("LI"); var y = document.createTextNode("Sudo"); x.appendChild(y); document.getElementById("GFG").appendChild(x); } </script> </body> </html> |
Output:
Before Clicking On Button:

After Clicking On Button:

Supported Browsers: The browsers supported by DOM Ul Object are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM Object Object
- HTML | DOM DT Object
- HTML| DOM Ins Object
- HTML | DOM DFN Object
- HTML DOM Aside Object
- HTML | DOM Bdo Object
- HTML | DOM dl Object
- HTML | Object tag
- HTML | DOM Ol Object
- HTML| DOM HR Object
- HTML | DOM Pre Object
- HTML | DOM BR Object
- HTML | DOM li Object
- HTML | DOM S Object
- HTML | DOM Kbd Object
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



