aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/api/element/getattribute/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ko/web/api/element/getattribute/index.html')
-rw-r--r--files/ko/web/api/element/getattribute/index.html53
1 files changed, 53 insertions, 0 deletions
diff --git a/files/ko/web/api/element/getattribute/index.html b/files/ko/web/api/element/getattribute/index.html
new file mode 100644
index 0000000000..c8f3947310
--- /dev/null
+++ b/files/ko/web/api/element/getattribute/index.html
@@ -0,0 +1,53 @@
+---
+title: Element.getAttribute()
+slug: Web/API/Element/getAttribute
+tags:
+ - API
+ - DOM
+ - 속성
+translation_of: Web/API/Element/getAttribute
+---
+<div>{{APIRef}}</div>
+
+<h2 id="Summary" name="Summary">요약</h2>
+
+<p><span class="seoSummary"><code>getAttribute()</code> 은 해당 요소에 지정된 값을 반환 합니다.</span> 만약 주어진 속성이 존재 하지 않는 다면, null 값이나 ""(빈문자열); 을 반환 할 것입니다. 자세한 사항은 {{Anch("Notes")}}  참조 하십시오.</p>
+
+<h2 id="Syntax" name="Syntax">문법</h2>
+
+<pre class="syntaxbox"><em>var attribute</em> = element.getAttribute(<em>attributeName</em>);
+</pre>
+
+<ul>
+ <li><code><em>attribute</em></code>는 <code><em>attributeName</em></code>의 값을 가지고 있는 문자열입니다.</li>
+ <li><code><em>attributeName</em></code>은 값을 얻고자 하는 속성의 이름입니다.</li>
+</ul>
+
+<h2 id="Example" name="Example">예제</h2>
+
+<pre class="brush:js">let div1 = document.getElementById("div1");
+let align = div1.getAttribute("align");
+
+alert(align); // id가 "div1"인 요소(element)의 align 값을 보여줍니다.
+</pre>
+
+<h2 id="Notes">Notes</h2>
+
+<p>When called on an HTML element in a DOM flagged as an HTML document, <code>getAttribute()</code> lower-cases its argument before proceeding.</p>
+
+<p>Essentially all web browsers (Firefox, Internet Explorer, recent versions of Opera, Safari, Konqueror, and iCab, as a non-exhaustive list) return <code>null</code> when the specified attribute does not exist on the specified element; this is what <a href="http://dom.spec.whatwg.org/#dom-element-getattribute" title="http://dom.spec.whatwg.org/#dom-element-getattribute">the current DOM specification draft</a> specifies. The old DOM 3 Core specification, on the other hand, says that the correct return value in this case is actually the <em>empty string</em>, and some DOM implementations implement this behavior. The implementation of <code>getAttribute()</code> in XUL (Gecko) actually follows the DOM 3 Core specification and returns an empty string. Consequently, you should use {{domxref("element.hasAttribute()")}} to check for an attribute's existence prior to calling <code>getAttribute()</code> if it is possible that the requested attribute does not exist on the specified element.</p>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<div>
+
+
+<p>{{Compat("api.Element.getAttribute")}}</p>
+</div>
+
+<h2 id="Specification" name="Specification">Specification</h2>
+
+<ul>
+ <li><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-666EE0F9">DOM Level 2 Core: getAttribute</a> (introduced in <a class="external" href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-getAttribute">DOM Level 1 Core</a>)</li>
+ <li><a class="external" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#apis-in-html-documents">HTML 5: APIs in HTML documents</a></li>
+</ul>