blob: 9c9f343239ddcbbb91915940f63587e6a96743d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
---
title: Element.id
slug: Web/API/Element/id
translation_of: Web/API/Element/id
---
<div>{{ ApiRef("DOM") }}</div>
<div> </div>
<p><strong><code>Element.id</code></strong> 속성은 요소의 식별자를 나타내며, HTML의 전역적인 id 속성을 반영합니다.</p>
<p>이 값은 도큐먼트 내에서 유일해야 하며, 종종 {{domxref("document.getElementById", "getElementById")}}를 사용하여 요소를 찾아내는데 사용됩니다. <code>id</code> 속성을 이용하는 다른 보편적인 방법에는 <a href="/en-US/docs/Web/CSS" title="CSS">CSS</a>로 도큐먼트를 스타일링 할때 <a href="/en-US/docs/Web/CSS/ID_selectors" title="Web/CSS/ID_selectors">ID를 선택자로 사용</a>하는 방법이 있습니다. </p>
<div class="note">
<p><strong>Note</strong>: 식별자는 대소문자를 구분하지만, 그래도 ID를 대소문자만 다르게 생성해서는 안됩니다. (<a href="/en-US/docs/Case_Sensitivity_in_class_and_id_Names" title="Case_Sensitivity_in_class_and_id_Names">클래스명과 식별자에서의 대소문자 구분</a>참고).</p>
</div>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">var <em>idStr</em> = <em>elt</em>.id; // 아이디를 가져옵니다.
<em>elt</em>.id = <em>idStr; // 아이디를 부여합니다</em>
</pre>
<ul>
<li><em><code>idStr</code></em>는 요소의 식별자입니다.</li>
</ul>
<h2 id="Specification" name="Specification">Specifications</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('DOM WHATWG', '#dom-element-id', 'id')}}</td>
<td>{{Spec2('DOM WHATWG')}}</td>
<td>No change from {{SpecName('DOM2 HTML')}}.</td>
</tr>
<tr>
<td>{{SpecName('DOM2 HTML', 'html.html#ID-63534901', 'id')}}</td>
<td>{{Spec2('DOM2 HTML')}}</td>
<td>No change from {{SpecName('DOM1')}}.</td>
</tr>
<tr>
<td>{{SpecName('DOM1', 'level-one-html.html#ID-63534901', 'id')}}</td>
<td>{{Spec2('DOM1')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat("api.Element.id")}}</p>
<h2 id="See_also">See also</h2>
<ul>
<li>The DOM <a href="/en-US/docs/Web/HTML/Global_attributes/id"><strong>id</strong></a> global attribute.</li>
</ul>
|