HTML | DOM li value Property
The DOM Li value Property is used to set or return the value of the value attribute of a list item. The value attribute is used to set the value for the list items and the other list item will be increment form that numeric value.
The value may be a number and alphabetical.
Syntax:
- Return the value property.
liObject.value
- It is used to set the value property.
liObject.value = number
Property Value: It contains a value i.e number which specify the value of the list item.
Return Value: It returns a numeric value which represents the value of the list item.
Example-1: This Example returns a value Property.
<!DOCTYPE html> <html> <head> <title> DOM li value Property </title> </head> <body> <h1>GeeksforGeeks</h1> <h2> DOM Li value Property </h2> <ol> <!-- Assigning id to 'li tag' --> <li id="GFG" value="100"> Geeks </li> <li>Sudo</li> <li>Gfg</li> <li>Gate</li> <li>Placement</li> </ol> <button onclick="myGeeks()"> Submit </button> <p id="sudo" style="font-size:25px; color:green;"> </p> <script> function myGeeks() { // Accessing 'li' tag. var g = document.getElementById("GFG").value; document.getElementById( "sudo").innerHTML = g; } </script> </body> </html> |
Output:
Before Clicking On Button:

After Clicking On Button:

Example-2: This Example sets the value Property.
<!DOCTYPE html> <html> <head> <title> DOM li value Property </title> </head> <body> <h1>GeeksforGeeks</h1> <h2> DOM Li value Property </h2> <ol> <!-- Assigning id to 'li tag' --> <li id="GFG" value="100"> Geeks </li> <li>Sudo</li> <li>Gfg</li> <li>Gate</li> <li>Placement</li> </ol> <button onclick="myGeeks()"> Submit </button> <p id="sudo" style="font-size:25px; color:green;"> </p> <script> function myGeeks() { // Accessing 'li' tag. var g = document.getElementById( "GFG").value = "200"; document.getElementById( "sudo").innerHTML = "The value was change form 100 to " + g; } </script> </body> </html> |
Output:
Before Clicking On Button:

After Clicking On Button:

Supported Browsers:
- Google Chrome
- Mozilla Firefox
- Edge
- Opera
- Safari
Recommended Posts:
- HTML | DOM name Property
- HTML | DOM id Property
- HTML | DOM value Property
- HTML | DOM dir Property
- HTML | DOM Bdo dir Property
- HTML | DOM specified Property
- HTML | DOM URL Property
- HTML | DOM classList Property
- HTML | DOM Fieldset name Property
- HTML | DOM Meter min Property
- HTML | DOM accessKey Property
- HTML | DOM attributes Property
- HTML | DOM Meter low Property
- HTML | DOM fullscreenElement Property
- HTML | DOM Meter value Property
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.



