How to add boolean attribute using JavaScript
To add a Boolean attribute: node.setAttribute(attributeName, ”); // example: document.body.setAttribute(‘hidden’, ”); Note the empty string as the second argument! Use node.removeAttribute(attributeName) to remove an attribute as mentioned by others.