Sets an attribute value of an Element. If the attribute does not exist, it will be created.
setAttr
Simple example:
const it = document.getElementById('item'); it.setAttr('foo', 'bar'));