--- id: javascript-dom-methods title: "JavaScript DOM Methods" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["DOM API", "DOM methods", "DOM properties", "HTML DOM API", "DOM Application Programming Interface"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.88 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["javascript", "js", "web", "frontend", "w3schools", "dom"] raw_sources: ["https://www.w3schools.com/js/js_htmldom_methods.asp"] applied_in: [] github_commit: "" --- # [[JavaScript DOM Methods]] ## π― ν μ€ ν΅μ°° (One-line insight) The DOM API is a set of methods (actions) and properties (values) that let JavaScript change the content, structure, and style of any HTML element. [S1] ## π§ ν΅μ¬ κ°λ (Core concepts) - **The DOM API** β the DOM API (Application Programming Interface) is a set of methods and properties that allow JavaScript to change the content, structure, and style of any HTML elements. [S1] - **Method vs property** β an API method is an action you can do on an HTML element; an API property is a value you can access on an HTML element. [S1] - **JavaScript is the language** β JavaScript is the programming language that operates the DOM API. [S1] - **document is the entry point** β `document` represents the HTML document; methods like `getElementById()` are called on it to retrieve elements. [S1] ## π§© μΆμΆλ ν¨ν΄ (Extracted patterns) - **Select with a method, mutate with a property** β call a document method to get an element, then assign to an element property (e.g. `innerHTML`). [S1] - **Categorized capabilities** β DOM methods group into selecting, accessing content, accessing/changing attributes, manipulating structure, and adding event handlers. [S1] ## π μΈλΆ λ΄μ© (Details) **HTML DOM API** [S1] The DOM API (Application Programming Interface) is a set of methods and properties that allow JavaScript to change the content, structure, and style of any HTML elements. An API method is an action that you can do on an HTML element, while an API property is a value that you can access on an HTML element. [S1] **Example** [S1] ```html
``` **Example Explained** β `document` represents the HTML document; `getElementById()` is a document method; `myPara` retrieves the element; `innerHTML` is an element property that can be modified. [S1] **HTML DOM API Abilities** [S1] The DOM API enables JavaScript to: find and select elements, change element content and attributes, add/remove/modify elements, change CSS styles, and add event listeners. [S1] **Selecting HTML Elements** [S1] | Method | Description | |--------|-------------| | `document.getElementById(id)` | Find element by id | | `document.getElementsByTagName(name)` | Find elements by tag name | | `document.getElementsByClassName(name)` | Find elements by class name | | `document.querySelector(selector)` | Find first matching CSS selector | | `document.querySelectorAll(selector)` | Find all matching CSS selectors | **Accessing Element Content** [S1] | Property | Description | |----------|-------------| | `element.innerHTML` | HTML content | | `element.textContent` | Text content | **Manipulating Structure** [S1] | Method | Description | |--------|-------------| | `document.createElement()` | Create new element | | `document.removeChild()` | Remove element | | `document.appendChild()` | Add element | | `document.replaceChild()` | Replace element | ## π οΈ μ μ© μ¬λ‘ (Applied in summary) The page's `#demo` paragraph example β retrieved with `getElementById()` and updated via `innerHTML` β is the canonical applied use. No external project/commit applications found in the source. ## π» μ½λ ν¨ν΄ (Code patterns) Select then mutate (language: JavaScript): ```javascript const myPara = document.getElementById("demo"); myPara.innerHTML = "Hello World!"; ``` ## βοΈ λͺ¨μ λ° μ λ°μ΄νΈ (Contradictions & updates) No contradictions found in the source. ## β κ²μ¦ μν λ° μ λ’°λ - **μν:** draft - **κ²μ¦ λ¨κ³:** conceptual (μ€μ μ μ© μ¬λ‘ λ°κ²¬ μ applied/validatedλ‘ μΉκ²© κ°λ₯) - **μΆμ² μ λ’°λ:** B (W3Schools β widely used educational reference, not a primary standards body) - **μ λ’° μ μ:** 0.88 - **μ€λ³΅ κ²μ¬ κ²°κ³Ό:** μ κ· μμ± (New discovery) ## π μ§μ κ·Έλν (Knowledge Graph) - **μμ/루νΈ:** [[JavaScript Tutorial]] - **κ΄λ ¨ κ°λ :** [[JavaScript HTML DOM]], [[JavaScript DOM Elements]], [[JavaScript DOM Changing HTML]], [[JavaScript DOM Event Listener]] - **μ°Έμ‘° λ§₯λ½:** The catalog of methods/properties referenced whenever selecting, reading, or restructuring DOM nodes. ## π μΆμ² (Sources) - [S1] W3Schools β JavaScript DOM Methods β https://www.w3schools.com/js/js_htmldom_methods.asp ## π λ³κ²½ μ΄λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript DOM Methods" page (Astra wiki-curation, P-Reinforce v3.1 format).