From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- files/ko/web/api/element/getattribute/index.html | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 files/ko/web/api/element/getattribute/index.html (limited to 'files/ko/web/api/element/getattribute') 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 +--- +
{{APIRef}}
+ +

요약

+ +

getAttribute() 은 해당 요소에 지정된 값을 반환 합니다. 만약 주어진 속성이 존재 하지 않는 다면, null 값이나 ""(빈문자열); 을 반환 할 것입니다. 자세한 사항은 {{Anch("Notes")}}  참조 하십시오.

+ +

문법

+ +
var attribute = element.getAttribute(attributeName);
+
+ + + +

예제

+ +
let div1 = document.getElementById("div1");
+let align = div1.getAttribute("align");
+
+alert(align); // id가 "div1"인 요소(element)의 align 값을 보여줍니다.
+
+ +

Notes

+ +

When called on an HTML element in a DOM flagged as an HTML document, getAttribute() lower-cases its argument before proceeding.

+ +

Essentially all web browsers (Firefox, Internet Explorer, recent versions of Opera, Safari, Konqueror, and iCab, as a non-exhaustive list) return null when the specified attribute does not exist on the specified element; this is what the current DOM specification draft specifies. The old DOM 3 Core specification, on the other hand, says that the correct return value in this case is actually the empty string, and some DOM implementations implement this behavior. The implementation of getAttribute() 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 getAttribute() if it is possible that the requested attribute does not exist on the specified element.

+ +

Browser compatibility

+ +
+ + +

{{Compat("api.Element.getAttribute")}}

+
+ +

Specification

+ + -- cgit v1.2.3-54-g00ecf