- attrName – the name of the attribute to set/change (required).
- attrValue – the value to set (required).
Returns:
The [[mdn>Web/API/HTMLElement|HTMLElement]] it was called on, thus allowing for command chaining.
===== Examples =====
Simple example:
const it = document.getElementById('item');
it.setAttr('foo', 'bar'));
===== See also =====
* [[toolbox:element:getattr:index|.getAttr()]]
* [[toolbox:element:hasattr:index|.hasAttr()]]
===== More information =====
* [[mdn>Web/API/Element/setAttribute|Element: setAttribute() method]] on MDN.