You are here: Reference > JavaScript > client-side > HTML DOM > properties > value (li)

value property (li)

Browser support:
Specifies or returns the number of a list item.
If you want to change the visual appearance of the counter displayed before all list items, use the listStyleType style property.

Syntax:

object.value;
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: value

Possible values:

String that sets or retrieves the number shown as a counter before the element. Only positive integers are allowed in Internet Explorer, Google Chrome and Safari. Negative integers are not allowed in Firefox. Opera supports both negative and positive integers.
Default:
Element Default value
ordered list 1 for the first list item and the number of the previous list item increased by one for other list items.
unordered list 0 in Internet Explorer, -1 in Firefox, Opera, Google Chrome and Safari.

Example HTML code 1:

This example illustrates the use of the value attribute:
<ol>
    <li value="2">first item
    <li>second item
    <li value="15">Third item
</ol>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the value property:
<head>
    <script type="text/javascript">
        function ChangeNumbering () {
            var list = document.getElementById ("myList");
            var liTags = list.getElementsByTagName ("li");
            for (var i = 0; i < liTags.length; i++) {
                liTags[i].value = i + 3;
            }
        }
    </script>
</head>
<body>
    <ol id="myList">
        <li value="1">first item
        <li>second item
        <li value="15">Third item
    </ol>

    <button onclick="ChangeNumbering ();">Change the numbering!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

External links:

User Contributed Comments

Post Content

Post Content