Check out example codes for "put new attribute on html tag using javascript". It will help you in understanding the concepts better.
Code Example 1
// thats how we set attribute.
document.getElementsByTagName("H1")[0].setAttribute("class", "democlass");
Code Example 2
document.getElementsByTagName("H1")[0].setAttribute("class", "democlass");
Code Example 3
// Here's what you do for the style attribute
span.setAttribute("style", "width:110%;float:center;left-margin:-10px;top-margin:-10;");
Code Example 4
// Selecting the element
var btn = document.getElementById("myBtn");
// Setting new attributes
btn.setAttribute("class", "click-btn");
btn.setAttribute("disabled", "");
Learn ReactJs, React Native from akashmittal.com