search
HomeWeb Front-endJS TutorialDetailed explanation of JS node knowledge_basic knowledge

Pay attention to the capitalization and make sure there is no mistake.
Attributes:
Attributes stores the node’s attribute list (read-only)
childNodes stores the node’s child node list (read-only)
dataType Returns the data type of this node
Definition The definition of the node given in DTD or XML mode (read-only)
Doctype Specifies the document type node (read-only)
documentElement Returns the root element of the document ( Readable and writable)
firstChild returns the first child node of the current node (read-only)
Implementation returns an XMLDOMImplementation object
lastChild returns the last child node of the current node (read-only)
nextSibling returns the current node The next sibling node (read-only)
nodeName returns the name of the node (read-only)
nodeType returns the type of the node (read-only)
nodeTypedValue stores the node value (readable and writable)
nodeValue returns The text of the node (readable and writable)
ownerDocument returns the root document containing this node (read-only)
parentNode returns the parent node (read-only)
Parsed returns whether this node and its child nodes have been parsed ( Read-only)
Prefix Returns the namespace prefix (read-only)
preserveWhiteSpace Specifies whether to preserve white space (read-write)
previousSibling Returns the previous sibling node of this node (read-only)
Text Returns this The text content of the node and its descendants (readable and writable)
url Returns the URL of the recently loaded XML document (read-only)
Xml Returns the XML representation of the node and its descendants (read-only)
Methods:
appendChild adds a new child node to the current node and places it after the last child node
cloneNode returns a copy of the current node
createAttribute creates a new attribute
createCDATASection creates a include Given a CDATA segment of data
createComment creates a comment node
createDocumentFragment creates a DocumentFragment object
createElement creates an element node
createEntityReference creates an EntityReference object
createNode creates a given type, name and namespace Node
createPorcessingInstruction creates an operation instruction node
createTextNode creates a text node including the given data
getElementsByTagName returns a collection of elements with the specified name
hasChildNodes returns whether the current node has child nodes
insertBefore before the specified node Insert child node
Load Import the XML document at the specified location
loadXML Import the XML document with the specified string
removeChild Remove the specified child node from the child node list
replaceChild Replace the specified child node from the child node list The child node
Save saves the XML file to the specified node
selectNodes performs the specified matching on the node and returns the matching node list
selectSingleNode performs the specified matching on the node and returns the first matching node
transformNode uses the specified style sheet to transform the node and its descendants
transformNodeToObject uses the specified style sheet to transform the node and its descendants into objects
DOM (Document Object Model)
DOM (Document Object Model) concept With the launch of DHTML, this API has made HTML even more powerful, but some friends who are learning DHTML are still a little confused, just because the current manual is not very scientific, and it is divided by letters
, which is inconvenient to read. In fact, the most important thing in DOM is To master the relationship between nodes (between node andnode), if you want to learn the DOM in DHTML, don't read all the properties and methods from beginning to end. You have Zhang Song's "photographic memory" from the Three Kingdoms Do you have the ability to "forget"? No, then let me analyze it:
In fact, what DOM teaches us is a hierarchical structure. You can understand it as a tree structure, just like our directory, a root directory. There are subdirectories under the root directory, and there are subdirectories under the subdirectory
...

Root node: DOM calls every object in the hierarchy a node (NODE) , take HTML hypertext markup language as an example: a root of the entire document is , which can be accessed in the DOM using
document.documentElement, which is the root node (ROOT) of the entire node tree

Child node: A node in the general sense. The largest child node below the root node is the main document area

. To access the body tag, you should write in the script:
document .body
All text and HTML tags within the body area are nodes of the document, which are called text nodes and element nodes (or label nodes) respectively. Everyone knows that HTML is just text in the final analysis.
No matter how Such a webpage must be composed of these two nodes, and can only be composed of these two nodes.
The relationship between nodes:
The relationship between nodes is also the most important joint in the DOM. How to quote it correctly When it comes to node objects, you must be clear about how each node of the node tree describes each other. In DHTML,
Javascript script uses a complete set of methods and attributes of each node object to describe other node objects.
Absolute reference of node:
Returns the root node of the document
document.documentElement
Returns the activated label node in the current document
document.activeElement
Returns the source node when the mouse is moved out
event.fromElement
Returns the source node that the mouse moves into
event.toElement
Returns the source node of the activated event
event.srcElement
Relative reference to the node: (Suppose the current node is node)
Returns the parent node
node.parentNode
node.parentElement
Returns the collection of child nodes (including text nodes and label nodes)
node.childNodes
Returns the collection of child label nodes
node.children
Returns the collection of child text nodes
node.textNodes
Returns the first child node
node.firstChild
Returns the last child node
node.lastChild
Return the next node of the same type
node.nextSibling
Return the previous node of the same type
node.previousSibling
Various operations of the node: (Suppose the current node is node)
Add a new label node Handle:
document.createElement(sNode) //The parameter is the label name of the node to be added, for example: newnode=document.createElement("div");
, add node:
Append child node:
node.appendChild(oNode) //The new node handle for oNode, for example: node.appendChild(newnode)
Apply label node
node.applyElment(oNode,sWhere)//oNode for living The newly added node handle, sWhere has two values: outside / inside, whether to add outside or inside the current node
Insert node
inode.insertBefore()
node.insertAdjacentElement()
node.replaceAdjacentText ()
, modify node:
Remove node
node.remove()
node.removeChild()
node.removeNode()
Replace node
node.replaceChild( )
node.replaceNode()
node.swapNode()
, copy node:
Return copy copy node reference
node.cloneNode(bAll)//bAll is a Boolean value, true / false Whether to clone all the child nodes of the node
, whether the node information
contains a certain node
node.contains()
whether there are child nodes
node.hasChildNodes()
*** *************************************************** **
The following is javascript operation xml
Statement
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
Python vs. JavaScript: Which Language Should You Learn?Python vs. JavaScript: Which Language Should You Learn?May 03, 2025 am 12:10 AM

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

JavaScript Frameworks: Powering Modern Web DevelopmentJavaScript Frameworks: Powering Modern Web DevelopmentMay 02, 2025 am 12:04 AM

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

The Relationship Between JavaScript, C  , and BrowsersThe Relationship Between JavaScript, C , and BrowsersMay 01, 2025 am 12:06 AM

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr

Node.js Streams with TypeScriptNode.js Streams with TypeScriptApr 30, 2025 am 08:22 AM

Node.js excels at efficient I/O, largely thanks to streams. Streams process data incrementally, avoiding memory overload—ideal for large files, network tasks, and real-time applications. Combining streams with TypeScript's type safety creates a powe

Python vs. JavaScript: Performance and Efficiency ConsiderationsPython vs. JavaScript: Performance and Efficiency ConsiderationsApr 30, 2025 am 12:08 AM

The differences in performance and efficiency between Python and JavaScript are mainly reflected in: 1) As an interpreted language, Python runs slowly but has high development efficiency and is suitable for rapid prototype development; 2) JavaScript is limited to single thread in the browser, but multi-threading and asynchronous I/O can be used to improve performance in Node.js, and both have advantages in actual projects.

The Origins of JavaScript: Exploring Its Implementation LanguageThe Origins of JavaScript: Exploring Its Implementation LanguageApr 29, 2025 am 12:51 AM

JavaScript originated in 1995 and was created by Brandon Ike, and realized the language into C. 1.C language provides high performance and system-level programming capabilities for JavaScript. 2. JavaScript's memory management and performance optimization rely on C language. 3. The cross-platform feature of C language helps JavaScript run efficiently on different operating systems.

Behind the Scenes: What Language Powers JavaScript?Behind the Scenes: What Language Powers JavaScript?Apr 28, 2025 am 12:01 AM

JavaScript runs in browsers and Node.js environments and relies on the JavaScript engine to parse and execute code. 1) Generate abstract syntax tree (AST) in the parsing stage; 2) convert AST into bytecode or machine code in the compilation stage; 3) execute the compiled code in the execution stage.

The Future of Python and JavaScript: Trends and PredictionsThe Future of Python and JavaScript: Trends and PredictionsApr 27, 2025 am 12:21 AM

The future trends of Python and JavaScript include: 1. Python will consolidate its position in the fields of scientific computing and AI, 2. JavaScript will promote the development of web technology, 3. Cross-platform development will become a hot topic, and 4. Performance optimization will be the focus. Both will continue to expand application scenarios in their respective fields and make more breakthroughs in performance.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),