관리 메뉴

드럼치는 프로그래머

[JavaScript] 모든 자식 엘레멘트 삭제하기 (Remove all children) 본문

★─Programing/☆─WebProgram

[JavaScript] 모든 자식 엘레멘트 삭제하기 (Remove all children)

드럼치는한동이 2016. 7. 25. 02:07

[Javascript] Removing all children using DOM


* HTML로 프로그래밍하다보면 모든 자식 노드를 삭제해야하는 경우가 생긴다 그럴때 사용하면 되는 간단한 팁이다.


var cell = document.getElementById("cell");

while ( cell.hasChildNodes() )
{
     cell.removeChild( cell.firstChild );       
}


[출처http://unikys.tistory.com/249


Comments