°³Ã¼¿¡¼­ ÀÚ½ÅÀÌ Àû¿ëÇÒ label ±â´ÉÀ» Á¦°øÇÒ ¼ö ÀÖ´Â °ªÀ» ¹ÝȯÇϰųª ¼³Á¤ÇÑ´Ù.

Àμö
: (¼Ó¼º ¹®ÀÚ¿­)
¼Ó¼º°ªÀº °³Ã¼¿¡¼­ ÀÚ½ÅÀÌ Àû¿ëÇÒ label ±â´ÉÀ» Á¦°øÇÒ ¼ö ÀÖ´Â °ªÀ» ³ªÅ¸³»´Â ¹®ÀÚ¿­ÀÌ´Ù.

ÀÌ ¼Ó¼ºÀº Àбâ/¾²±âÀÌ¸ç µðÆúÆ®°ªÀº ¾ø´Ù.

Ư±â

HTML 4.0 Ç¥ÁØ¿¡¼­ ±â´É¼ºÀ» Á¤ÀÇÇÏ¿´À¸³ª Àû¿ëµÇÁö ¾Ê¾Ò¾ú´Ù.

ÀÛ¼ºÀÚ°¡ ±â´ÉÀ» Á¤ÀÇÇÏ¿© ºÎ¿©ÇÏÁö ¾ÊÀ¸¸é ±â´É¼ºÀÌ ¾ø´Ù.

Àû¿ë
°³Ã¼scriptHTML±Ô°ÝIE
Âü°í

ÀÌ ¼Ó¼ºÀº HTML 4.0°ú (¿µ¹®) W3C DOM Level 1(Document Object Model)¿¡¼­ Á¤ÀǵǾú´Ù.


<FORM name="formObj">
<SELECT name="selObj">
<OPTGROUP name="optGroupObj" label="¼±Åà ±¸·ì" style="color:green">
<OPTION name="op1Obj">¼±ÅÃÇ׸ñ 1
<OPTION name="op2Obj" label="option2">¼±ÅÃÇ׸ñ 2 style="color:red"
<OPTION name="op3Obj">¼±ÅÃÇ׸ñ 3
<OPTION name="op4Obj">¼±ÅÃÇ׸ñ 4
</OPTGROUP>
<OPTION name="op5Obj">¼±ÅÃÇ׸ñ 5
</SELECT>
</FORM>

<SCRIPT>
obj=document.all.tags("optGroup")[0];
str='document.all.tags("optGroup")[0].label="'+obj.label+'"<BR>';
str+='document.all.tags("opttion")[0].label="'+obj.children[1].label+'"<BR>';
document.write(str);
</SCRIPT>