value property (li)
Specifies or returns the number of a list item.
- In an ordered list, a number is displayed before every list item.
- In an unordered list, the number has no visual effect.
Syntax:
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?
|
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?
|
Supported by objects:
HTML elements:
External links:
User Contributed Comments