JavaScript Reference/Javascript Properties/label — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 08:21, 26 мая 2010

"label" Example

<!-- 
Example revised from 
The Web Programmer"s Desk Reference
by Lazaro Issi Cohen and Joseph Issi Cohen 
ISBN: 1593270119
Publisher: No Starch Press 2004
-->    
<html>
<body>
<form name="form2" method="post" action="">
<select name="select1">
<optgroup id="optg1"> 
    <option id="opt1_1">first</option>
    <option>second</option>
    <option>third</option>
</optgroup>
<optgroup id="optg2">
    <option>first item in second group </option>
    <option id="opt2_2">second item in second group </option>
    <option>third item in second group </option>
</optgroup> 
<script language="JavaScript">
    document.getElementById("optg1").label = "first group";
    document.getElementById("optg2").label = "second group";
</script>
</select>
</form>
</body>
</html>



"label" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<option>                                                      |
+----------------+--------------------------------------------------------------+



"label" Syntax and Note

Note:
Read and write property. 
For the <optgroup>,         helps group list items in a <select> element. 
For the <option>,           used to record additional information regarding 
                            the element.
    
Syntax:
    
document.getElementById("elementID").label = value
document.all.elementID.label = value // IE only