html element add attribute code example
Example 1: html change attribute
element.setAttribute(name, value);
var d = document.getElementById("d1");
d.setAttribute("align", "center");
Example 2: set attribute javascript
Element.setAttribute(name, value);
Example 3: set property dom javascrpt
document.getElementsByTagName("H1")[0].setAttribute("class", "democlass");