¼±ÅÃ(Option) ±¸·ìÀÇ ¶óº§(label)À» ¹ÝȯÇϰųª ¼³Á¤ÇÑ´Ù.

Àμö
: (¼Ó¼º ¹®ÀÚ¿­)
¼Ó¼º°ªÀº ¼±ÅÃ(Option) ±¸·ìÀÇ ¶óº§(label)À» ³ªÅ¸³»´Â ¹®ÀÚ¿­ÀÌ´Ù.

optGroupÀÇ select ¿¤·¹¸àÆ®¿¡ ÀÖ´Â ¶óº§ÀÇ ¹®ÀÚ¿­ÀÌ´Ù.

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

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

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


<FORM name="formObj">
<SELECT name="selObj">
<OPTGROUP name="optGroupObj" label="¼±Åà ±¸·ì" style="color:blue">
<OPTION name="op1Obj">¼±ÅÃÇ׸ñ 1
<OPTION name="op2Obj" label="option2">¼±ÅÃÇ׸ñ 2
<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>