id ¾ÖÆ®¸®ºäÆ®ÀÇ °ª¿¡ ¸Â´Â óÀ½ °³Ã¼¸¦ ¹ÝȯÇÑ´Ù.
¹Ýȯ°ª oElemÀº ÁöÁ¤µÈ ¿¤·¹¸àÆ® ÀνÄÀÚ(id)À» °®´Â óÀ½ÀÇ °³Ã¼ÀÌ´Ù.
¸¸ÀÏ id °ªÀÌ Ä÷º¼Ç¿¡ ¼Ò¼ÓµÇ¸é,getElementById ¸Þ¼µå´Â ±× Ä÷¹¼Ç¿¡¼ Á¦ÀÏ Ã³À½ °³Ã¼À» ¹ÝȯÇÑ´Ù.
°³Ã¼ | script | IE |
---|
ÀÌ ¸Þ¼µå´Â (¿µ¾î)DOM Level 1(Document Object Model Level 1)¿¡¼ Á¤ÀǵǾú´Ù.
getElementById ¸Þ¼µå·Î id ¼Ó¼º°ªÀÌ id2ÀÎ ¿¤·¹¸àÆ®¸¦ ã¾Æ ³»¿ë ÅؽºÆ®¸¦ µð½ºÇ÷¹ÀÌÇÑ´Ù.
<SCRIPT> function doShow(){ showA.innerHTML='document.getElementsById("id2").innerText='+document.getElementById("id2").innerText; } </SCRIPT> <DIV id="id1">À̼ø½Å</DIV> <DIV id="id2">È«±æµ¿</DIV> <DIV id="id3">Lincon</DIV> <INPUT type="button" value="id ¾ò±â" onclick="doShow()"> <DIV id=showA>°á°ú Ç¥½Ãâ</DIV>