Q:

put new attribute on html tag using javascript

	// Selecting the element
    var btn = document.getElementById("myBtn");
	
    // Setting new attributes
    btn.setAttribute("class", "click-btn");
    btn.setAttribute("disabled", "");
0
// thats how we set attribute.
 document.getElementsByTagName("H1")[0].setAttribute("class", "democlass"); 
2
// Here's what you do for the style attribute
span.setAttribute("style", "width:110%;float:center;left-margin:-10px;top-margin:-10;");
1
document.getElementsByTagName("H1")[0].setAttribute("class", "democlass");
1

New to Communities?

Join the community