You are here: Reference > JavaScript > client-side > HTML DOM > properties > label (option)

label property (option)

Browser support:
Sets or retrieves a short label for an option element.
This property works differently in different browsers, do not use it. Use the value property instead.

Syntax:

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

Possible values:

String that sets or retrieves the label of the option.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the label attribute:
<select id="mySelect" size="2">
    <option label="Apple">Malus domestica
    <option />Pear
</select>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the label property:
<head>
    <script type="text/javascript">
        function GetLabel () {
            alert (mySelect.options[0].label);
        }
    </script>
</head>
<body>
    <select id="mySelect" size="2">
        <option label="Apple">Malus domestica
        <option />Pear
    </select>

    <button onclick="GetLabel ();">Get first option label property!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content