Li value Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Li

Description

The value property sets or gets the value attribute of a list item, which sets the value of a list item, and the following list items will increment from that number.

The value must be a number and can only be used in ordered lists <ol>.

Set the value property with the following Values

Value Description
number Sets the value of the list item

Return Value

A Number, representing the value of the list item

The following code shows how to Set the list items to increment from the number "200":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<ol>
  <li id="myLi" value="100">CSS</li>
  <li>HTML</li>
  <li>Javascript</li>
</ol>//from w  w w  . jav a 2s  . com

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    document.getElementById("myLi").value = 100;
    
}
</script>

</body>
</html>

Related Tutorials