name ¾ÖÆ®¸®ºäÆ®ÀÇ °ª¿¡ ±âÃÊÇÏ¿© °³Ã¼µéÀÇ Ä÷º¼ÇÀ» ¹ÝȯÇÑ´Ù.
¹Ýȯ°ª oCollectionÀº ÁöÁ¤µÈ ¿¤·¹¸àÆ® À̸§(name)µéÀ» °®´Â °³Ã¼µéÀÇ Ä÷º¼ÇÀÌ´Ù.
getElementsByName ¸Þ¼µå, ¹®¼¿¡ ÀÖ´Â ÁöÁ¤ÇÑ name À̳ª id ¾ÖÆ®¸®ºäÆ® °ªÀ» °®´Â ¸ðµç ¿¤·¹¸àÆ®¸¦ ¹ÝȯÇÑ´Ù.
name°ú id ¾ÖÆ®¸®ºäÆ®¸¦ Áö¿øÇÏ´Â ¿¤·¹¸àÆ®´Â getElementsByName ¸Þ¼µå¿¡ ÀÇÇÏ¿© ¹ÝȯµÈ Ä÷º¼Ç¿¡ Æ÷ÇÔµÇÁö¸¸, expando name ¿¤·¹¸àÆ®´Â Æ÷ÇÔµÇÁö ¾Ê´Â´Ù.
°³Ã¼ | script | IE |
---|
ÀÌ ¸Þ¼µå´Â (¿µ¾î)DOM Level 1(Document Object Model Level 1)¿¡¼ Á¤ÀǵǾú´Ù.
getElementsByName ¸Þ¼µå¸¦ »ç¿ëÇÏ¿© nameÀÌ 'name' ÀÎ °³Ã¼µéÀÇ Ä÷º¼ÇÀ» ¹ÝȯÇÑ´Ù. id°¡ 'name' ÀÎ °³Ã¼°¡ Æ÷ÇԵȴÙ.
<SCRIPT> function getNames(nb){ var aInput=document.getElementsByName('name'); showA.innerHTML=aInput[nb].value+'<BR>'; showA.innerHTML+='document.getElementsByName("name").length='+document.getElementsByName("name").length; } </SCRIPT> <DIV id="name" style="border:solid 1 blue;width:600">name DIV</DIV> <INPUT type="text" name="name" value="À̼ø½Å"> <INPUT type="text" name="name" value="È«±æµ¿"> <INPUT type="text" name="name" value="Lincon"><BR> <INPUT type="button" value="À̸§ #0 ¾ò±â" onclick="getNames(0)"> <INPUT type="button" value="À̸§ #1 ¾ò±â" onclick="getNames(1)"> <INPUT type="button" value="À̸§ #2 ¾ò±â" onclick="getNames(2)"> <INPUT type="button" value="À̸§ #3 ¾ò±â" onclick="getNames(3)"> <DIV id=showA>°á°ú Ç¥½Ãâ</DIV>