개체가 자식들을 가지고 있는가를 나타내는 부울값을 반환한다.

Script[bVal=]object.hasChildNodes()
인수/파라메터
파라메터

파라메터는 없다.

반환값

반환값 bVal은 자식개체를 가지고 있는가를 나타내는 부울값이다.

true 개체가 HTML ELEMENT들이나 TextNode 개체들을 가지고 있다.
false 개체가 HTML ELEMENT들이나 TextNode 개체들을 가지고 있지 않다.
특기

개체가 HTML ELEMENT들이나 TextNode 개체들을 가지고 있으면, childNodes 컬렉션을 통하여 접속할 수 있다.

이 메서드는 IE6에서부터 attribute 개체에도 적용된다.

적용
개체scriptIE
aa.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
acronymacronym.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
addressaddress.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
appletapplet.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
areaarea.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
attributeattribute.hasChildNodes()IE6(win32)
bb.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
basebase.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
baseFontbaseFont.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
bdobdo.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
bigbig.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
blockQuoteblockQuote.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
bodybody.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
brbr.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
buttonbutton.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
captioncaption.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
centercenter.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
citecite.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
codecode.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
colcol.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
colGroupcolGroup.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
commentcomment.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
dddd.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
deldel.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
dfndfn.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
dirdir.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
divdiv.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
dldl.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
dtdt.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
emem.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
embedembed.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
fieldSetfieldSet.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
fontfont.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
formform.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
frameframe.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
frameSetframeSet.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
headhead.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
hnhn.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
hrhr.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
htmlhtml.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
ii.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
iFrameiFrame.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
imgimg.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
buttonbutton.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
checkboxcheckbox.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
FileUploadFileUpload.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
imageimage.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
passwordpassword.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
radioradio.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
resetreset.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
submitsubmit.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
texttext.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
insins.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
kbdkbd.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
labellabel.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
legendlegend.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
lili.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
linklink.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
listinglisting.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
mapmap.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
marqueemarquee.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
menumenu.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
nextIDnextID.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
olol.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
OptionOption.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
pp.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
plainTextplainText.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
prepre.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
qq.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
ss.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
sampsamp.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
scriptscript.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
selectselect.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
smallsmall.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
spanspan.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
strikestrike.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
strongstrong.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
subsub.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
supsup.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
tabletable.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
tBodytBody.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
tdtd.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
textAreatextArea.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
tFoottFoot.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
thth.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
tHeadtHead.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
titletitle.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
trtr.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
tttt.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
uu.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
ulul.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
varvar.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
xmpxmp.hasChildNodes()IE5(win16,win32,unix,mac),IE5.5(ce)
참조
(영문)DOM(W3C Document Object Model)

이 메서드는 (영문)DOM1(W3C Document Object Model Level 1)에서 정의되었다.


method
hasChildNodes 메서드
hasChildNodes</b> 메서드이전페이지로페이지 맨위로페이지 맨아래로

간단한 hasChildNodes 메서드 예제

결과 표시창
<DIV id=showA title="결과">결과 표시창</DIV>
<BUTTON onClick="doShow()">점검한다</BUTTON>
<SCRIPT>
function doShow(){
  coll=document.all;
  hasChild=noChild='';
  for (i=0;i< coll.length;i++){
    if(coll[i].hasChildNodes()) hasChild+=coll[i].nodeName+', ';
    else noChild+=coll[i].nodeName+', ';
  }
  str='<FONT color=blue>자식이 있는 엘레멘트 :</FONT> '+hasChild+'<BR>';
  str+='<FONT color=red>자식이 없는 엘레멘트 :</FONT> '+noChild+'<BR>';
  showA.innerHTML=str;
}
</SCRIPT>
method
hasChildNodes 메서드
견본
이전페이지로페이지 맨위로
최종 수정:
05/04/2025 13:01:37
KoXo Homepage
All right reserved
비정상적인 방식으로 프레임없이 페이지에 접속하면 자주 오류가 발생됩니다.
오류가 나면 정상적 접속으로 시도해 보세요.
http://koxo.com/lang/js/method/hasChildNodes.html