---
# System prepended metadata

title: setAttribute

---

# setAttribute

看似是改變　DOM 中元素的屬性值，但是其實該方法設置的是**預設值**，而非**當前值**

> Using setAttribute() to modify certain attributes, most notably value in XUL, works inconsistently, as the attribute specifies the default value. To access or modify the current values, you should use the properties. For example, use Element.value instead of Element.setAttribute(). 

如果要改當前值，用點記法取出想要設置的屬性直接賦值即可。