adding attribute vanilla js code example
Example 1: javascript update attribute
var element = document.getElementById("elemId");
element.setAttribute("attributeName", "value");
Example 2: set property dom javascrpt
document.getElementsByTagName("H1")[0].setAttribute("class", "democlass");