#Attribute
속성을 사용할땐 노드명.속성명 으로 사용한다
parentNode : 현재 노드의 부모의 참조값
childNodes : 현재 노드의 자식들을 NodeList로 가지고 있음.
firstChild : 첫번째 자식노드의 참조값
lastChild : 마지막 자식노드의 참조값
previousSibling : 현재 노드 이전의 형제의 참조값
nextSibling : 현재 노드 다음에 있는 형제의 참조값
# Method
1. appendChild(childNode)
: 자식 노드를 추가하는 메소드. 매개변수로 받은 노드를 자식 노드로 추가한다. 이미 자식노드가 있다면 순서대로 추가된다.
appendChild
modified in DOM Level 3newChild
to the end of the list of children of this node. If the newChild
is already in the tree, it is first removed.
newChild
of typeNode
- The node to add.
If it is aDocumentFragment
object, the entire contents of the document fragment are moved into the child list of this node
The node added. |
HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the WRONG_DOCUMENT_ERR: Raised if NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the previous parent of the node being inserted is readonly. NOT_SUPPORTED_ERR: if the |
2. insertBefore(newNode, refNode)
: 기존의 노드 앞에 새로운 노드를 추가한다. 두번째 매개변수로 받은 자식 노드 앞에 첫번째 매개변수로 받은 새로운 자식 노드를 추가한다.
insertBefore
modified in DOM Level 3newChild
before the existing child node refChild
. If refChild
is null
, insert newChild
at the end of the list of children.If
newChild
is a DocumentFragment
object, all of its children are inserted, in the same order, before refChild
. If the newChild
is already in the tree, it is first removed.
Note: Inserting a node before itself is implementation dependent.
The node being inserted. |
HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the WRONG_DOCUMENT_ERR: Raised if NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the parent of the node being inserted is readonly. NOT_FOUND_ERR: Raised if NOT_SUPPORTED_ERR: if this node is of type |
3. removeChild(childNode)
: 매개변수로 받은 자식노드를 삭제하고 삭제한 자식 노드를 반환한다.
removeChild
modified in DOM Level 3oldChild
from the list of children, and returns it.
oldChild
of typeNode
- The node being removed.
The node removed. |
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. NOT_FOUND_ERR: Raised if NOT_SUPPORTED_ERR: if this node is of type |
4. replaceChild(newChild, oldChild)
: 기존의 자식노드를 새로운 자식노드로 바꾸는 함수. 교체된 노드가 반환된다.
replaceChild
modified in DOM Level 3oldChild
with newChild
in the list of children, and returns the oldChild
node.If
newChild
is a DocumentFragment
object, oldChild
is replaced by all of the DocumentFragment
children, which are inserted in the same order. If the newChild
is already in the tree, it is first removed.
Note: Replacing a node with itself is implementation dependent.
The node replaced. |
HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the WRONG_DOCUMENT_ERR: Raised if NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of the new node is readonly. NOT_FOUND_ERR: Raised if NOT_SUPPORTED_ERR: if this node is of type |
'JavaScript' 카테고리의 다른 글
JSON (0) | 2016.04.08 |
---|---|
HTML DOM 함수 - document interface (0) | 2016.04.06 |
DOM (0) | 2016.04.06 |
내장 객체 - String (0) | 2016.04.05 |
Array (0) | 2016.04.04 |