Home > Web Front-end > JS Tutorial > body text

The nearest related node access method of a node in javascript_javascript skills

WBOY
Release: 2016-05-16 17:40:09
Original
1037 people have browsed it

In JavaScript, for each node in the document, there is

parentNode - parent node

firstChild - the first child node

lastChild - the last child node

previousSibling - the immediately preceding sibling node

nextSibling - the immediately following sibling node

Five related nodes, these nodes may not exist , is null. For example, document does not contain parent nodes, and text node (TextNode) does not contain child nodes.

This allows you to take a short trip and visit some related nodes of the current node.

In addition, there are childNode[] (contains all child nodes) and children[] (contains only child nodes of type element node, excluding text node textNode).

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!