W3Schools 튜토리얼을 P-Reinforce v3.1 포맷으로 위키화(영어 본문, 한/영 섹션 헤더). - Topic_HTML: 59문서 (튜토리얼+예제, 레퍼런스/메타 제외) - Topic_CSS: 190문서 (메인 + Advanced/Flexbox/Grid/RWD 전체) - Topic_JavaScript: 120문서 (코어 언어; Temporal/DOM상세/BOM/WebAPI/AJAX/jQuery/Graphics 등은 후속) 각 폴더 00_INDEX.md(MOC) 포함. 코드 verbatim, 미확인분은 "Not found in source" 표기. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
6.2 KiB
id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
| id | title | category | status | verification_status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | created_at | updated_at | review_reason | merge_history | tags | raw_sources | applied_in | github_commit | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| javascript-dom-elements | JavaScript DOM Elements | Frontend | draft | conceptual |
|
B | 0.88 | 2026-06-23 | 2026-06-23 |
|
|
JavaScript DOM Elements
🎯 한 줄 통찰 (One-line insight)
Before you can manipulate an HTML element with JavaScript, you must first find it — by id, tag name, class name, CSS selector, or via the built-in HTML object collections. [S1]
🧠 핵심 개념 (Core concepts)
- Find first, then manipulate — often you want to manipulate HTML elements, and to do so you have to find the elements first. [S1]
- By id is the easiest — the easiest way to find an HTML element in the DOM is by using the element id; it returns the element as an object, or
nullif not found. [S1] - Collections by tag / class —
getElementsByTagName()finds all elements of a tag type;getElementsByClassName()finds all elements sharing a class name. [S1] - CSS selectors —
querySelector()returns the first match for a CSS selector;querySelectorAll()returns all matches. [S1] - HTML object collections — predefined collections such as
document.formsanddocument.imagesalso give access to elements. [S1]
🧩 추출된 패턴 (Extracted patterns)
- One element vs many — id and
querySelector()return a single element; tag-name, class-name, andquerySelectorAll()return collections you iterate over. [S1] - Loop over a collection — index into the returned collection (e.g.
x.elements[i].value) to read each member. [S1] - No
#for getElementById — pass the bare id, not a CSS-style selector. [S1]
📖 세부 내용 (Details)
Finding HTML Elements [S1] Often, with JavaScript, you want to manipulate HTML elements. To do so, you have to find the elements first. [S1]
Finding HTML Element by Id [S1]
The easiest way to find an HTML element in the DOM is by using the element id. It returns the element as an object if found, or null if not found. [S1]
const element = document.getElementById("intro");
Finding HTML Elements by Tag Name [S1]
const element = document.getElementsByTagName("p");
Finding HTML Elements by Class Name [S1]
If you want to find all HTML elements with the same class name, use getElementsByClassName(). [S1]
const x = document.getElementsByClassName("intro");
Finding HTML Elements by CSS Selectors [S1]
If you want to find all HTML elements that match a specified CSS selector (id, class names, types, attributes, values of attributes, etc.), use the querySelectorAll() method. [S1]
const x = document.querySelectorAll("p.intro");
The querySelector() Method — returns the first element that matches a specified CSS selector. [S1]
The querySelectorAll() Method — returns all elements that match a specified CSS selector. [S1]
Finding HTML Elements by HTML Object Collections [S1] The source also shows iterating over a collection (here a form's elements): [S1]
const x = document.forms["frm1"];
for (let i = 0; i < x.length; i++) {
text += x.elements[i].value + "<br>";
}
Accessible HTML object collections include: document.anchors, document.body, document.documentElement, document.embeds, document.forms, document.head, document.images, document.links, document.scripts, and document.title. [S1]
Common Mistakes [S1]
- Using
#insidegetElementById()(wrong:"#demo"). [S1] - Forgetting that
querySelector()returns only the first match. [S1]
🛠️ 적용 사례 (Applied in summary)
The page's snippets — selecting by id, tag, class, and CSS selector, and looping a form's elements collection — are the canonical applied examples. No external project/commit applications found in the source.
💻 코드 패턴 (Code patterns)
Four ways to find elements (language: JavaScript):
const byId = document.getElementById("intro");
const byTag = document.getElementsByTagName("p");
const byClass = document.getElementsByClassName("intro");
const bySelector = document.querySelectorAll("p.intro");
Iterate a collection:
const x = document.forms["frm1"];
for (let i = 0; i < x.length; i++) {
text += x.elements[i].value + "<br>";
}
⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
- Use
getElementById()when the element has a unique id — fastest, returns one object. [S1] - Use
getElementsByTagName()/getElementsByClassName()to retrieve a live collection of multiple elements. [S1] - Use
querySelector()for the first match of any CSS selector, andquerySelectorAll()for all matches when you need full CSS-selector expressiveness. [S1]
⚖️ 모순 및 업데이트 (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 Methods, JavaScript DOM Changing HTML, JavaScript DOM Changing CSS
- 참조 맥락: The element-selection step that precedes any content, style, or event manipulation.
📚 출처 (Sources)
- [S1] W3Schools — JavaScript DOM Elements — https://www.w3schools.com/js/js_htmldom_elements.asp
📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript DOM Elements" page (Astra wiki-curation, P-Reinforce v3.1 format).