Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use javascript document object

Shulou Source: shulou.com Published: 2022-05-31 11:46:17 11月11日 Update

This article mainly introduces the relevant knowledge of how to use the javascript document object, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this article on how to use the javascript document object. Let's take a look at it.

Methods for js document objects: addEventListener (), adoptNode (node), close (), createAttribute (), open (), write (), writeln (), renameNode (), and so on.

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

Document object

Every HTML document loaded into the browser becomes a Document object.

The Document object gives us access to all the elements in the HTML page from the script.

Tip: the Document object is part of the Window object and can be accessed through the window.document property.

Methods of Document object

The method describes addEventListener () to add a handle to the document adoptNode (node) to return the adapded node from another document to the current document. Close () closes the output stream opened with the document.open () method and displays the selected data. CreateAttribute () creates an attribute node createDocumentFragment () creates an empty DocumentFragment object and returns it. CreateElement () creates the element node. CreateTextNode () creates a text node. GetElementsByClassName () returns a collection of all the elements in the document with the specified class name as NodeList objects. GetElementById () returns a reference to the first object that owns the specified id. GetElementsByName () returns a collection of objects with the specified name. GetElementsByTagName () returns a collection of objects with the specified tag signature. ImportNode () copies a node from another document to that document for application. Normalize () deletes empty text nodes and connects neighboring nodes normalizeDocument () deletes empty text nodes, and open () that connects neighboring nodes opens a stream to collect output from any [xss_clean] () or [xss_clean] ln () methods. QuerySelector () returns the first element in the document that matches the specified CSS selector querySelectorAll () document.querySelectorAll () is a new method introduced in HTML5 that returns a list of all element nodes of the matching CSS selector in the document removeEventListener () removes the event handle (added by the addEventListener () method) renameNode () renames the element or attribute node. Write () writes HTML expressions or JavaScript code to the document. Writeln () is equivalent to the write () method, except that a newline character is written after each expression. This is the end of the article on "how to use javascript document objects". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to use javascript document objects". If you want to learn more knowledge, you are welcome to follow the industry information channel.

Tags: Objects nodes documents methods elements attributes text knowledge content handles articles expressions output selections differences events code values names newline characters Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Linux Shulou Technology Xiaomi Apple