JavaScript 参考手册 目录

HTML DOM Document

AI 编程助手,豆包旗下的编程助手,提供智能补全、智能预测、智能问答等能力,节省开发时间,释放脑海中的创造力,支持 VSCode,点击体验 AI

The Document object represents the entire HTML document. It is the root node of the HTML document tree, and provides access to all elements and properties within the document.

Properties

  1. document.title: Returns the title of the document.
  2. document.URL: Returns the URL of the document.
  3. document.body: Returns the <body> element of the document.
  4. document.head: Returns the <head> element of the document.
  5. document.documentElement: Returns the <html> element of the document.
  6. document.doctype: Returns the <!DOCTYPE> declaration of the document.
  7. document.domain: Returns the domain of the document.

Methods

  1. document.getElementById(id): Returns the element with the specified ID.
--- ------- - -------------------------------------
  1. document.getElementsByClassName(className): Returns a collection of elements with the specified class name.
--- -------- - -------------------------------------------
  1. document.getElementsByTagName(tagName): Returns a collection of elements with the specified tag name.
--- -------- - -------------------------------------
  1. document.createElement(tagName): Creates a new element with the specified tag name.
--- ---------- - ------------------------------
  1. document.createTextNode(text): Creates a new text node with the specified text content.
--- -------- - ------------------------------- ---------
  1. document.querySelector(selector): Returns the first element that matches the specified CSS selector.
--- ------- - -----------------------------------
  1. document.querySelectorAll(selector): Returns a collection of elements that match the specified CSS selector.
--- -------- - -----------------------------------------

Events

  1. DOMContentLoaded: Fired when the initial HTML document has been completely loaded and parsed.
  2. load: Fired when all resources (images, stylesheets, scripts, etc.) have been loaded.
  3. click: Fired when a mouse click is detected on an element.
  4. submit: Fired when a form is submitted.

This is just a brief overview of the HTML DOM Document object. There are many more properties, methods, and events available for working with the document in JavaScript.


上一篇:存储对象
下一篇:HTML DOM 元素对象