--- title: Element.removeAttribute() slug: Web/API/Element/removeAttribute tags: - API - DOM - Element - Method - Reference translation_of: Web/API/Element/removeAttribute ---
Element.removeAttribute()
메서드는 요소에서 주어진 이름의 특성을 제거합니다.
element.removeAttribute(attrName);
attrName
{{jsxref("undefined")}}.
많은 특성은 {{jsxref("null")}}을 대입했을 때 예상치 못한 동작을 하곤 합니다. 그러므로 특성을 삭제할 때 null
을 직접 대입하거나, {{domxref("Element.setAttribute", "setAttribute()")}}의 매개변수로 제공하기보단 removeAttribute()
메서드를 사용해야 합니다.
// Given: <div id="div1" align="left" width="200px"> document.getElementById("div1").removeAttribute("align"); // Now: <div id="div1" width="200px">
Specification | Status | Comment |
---|---|---|
{{SpecName('DOM WHATWG', '#dom-element-removeattribute', 'Element" removeAttribute')}} | {{Spec2('DOM WHATWG')}} |
{{Compat("api.Element.removeAttribute")}}