adding attribute to html element code example
Example 1: set attribute javascript
Element.setAttribute(name, value);
Example 2: set property dom javascrpt
document.getElementsByTagName("H1")[0].setAttribute("class", "democlass");
Element.setAttribute(name, value);
document.getElementsByTagName("H1")[0].setAttribute("class", "democlass");