html change attribute
snippet in html

javascript setattribute

user6397

element.setAttribute(<name>, <value>);
// ex
var aElement = document.querySelector("a"); 
aElement.setAttribute("href", "https://isitchristmas.com/"); 
// same as <a href="https://isitchristmas.com/"></a>

html change attribute

user3570

element.setAttribute(name, value);


var d = document.getElementById("d1"); 
d.setAttribute("align", "center");