📄 e527. getting a node relative to another node in a dom document.txt
字号:
This example demonstrates the various methods for using a node to retrieve related nodes --- parent, child, etc.
// Get the parent
Node parent = node.getParentNode();
// Get children
NodeList children = node.getChildNodes();
// Get first child; null if no children
Node child = node.getFirstChild();
// Get last child; null if no children
child = node.getLastChild();
// Get next sibling; null if node is last child
Node sibling = node.getNextSibling();
// Get previous sibling; null if node is first child
sibling = node.getPreviousSibling();
// Get first sibling
sibling = node.getParentNode().getFirstChild();
// Get last sibling
sibling = node.getParentNode().getLastChild();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -