(팁: 크롬으로 javascript 개발시 F12 키가 debug모드이다 : 메뉴엔 Ctrl-Shft-J)
JavaScript의 객체 상속도를 잘 나타낸 그림은 다음과 같다. 참고사이트:devbox
DOM구조에서 거의 모든 object들이 Node를 상속받아서 만들어 졌다고 보면된다.
그런데 개발시에는 node API를 쓰면 필요없는 tag등이 한번씩 나오는 경우가 있어서
위한 children() 함수를 더 많이 쓰게 된다.
<많이 쓰는 코드>
document.getElementById('aa').children -> HTMLCollections 를 리턴함.
(document.getElementByxxx부터 해서, Element를 특히 많이 씀)
document.getElementById('aa').children.item(i) --> Element 리턴.
jquery의 경우는 : $('#aa')[0].childNodes[0].nodeValue;
$($('h1').contents().get(0)).text(); //.get(0)=[0]
$('h1').contents().each(function() {
if(this.nodeType == 3) { }
removeChild(e)
appendChild(e)
document.createElement('div')