1var element = document.getElementById('btnBuild');
2element.setAttribute("disabled", "disabled");
1 // Selecting the element
2 var btn = document.getElementById("myBtn");
3
4 // Setting new attributes
5 btn.setAttribute("class", "click-btn");
6 btn.setAttribute("disabled", "");
1//This is for creating an attribute with setAttributeNode
2<script>
3var f = document.querySelector("#menu-item-16 > a");// Get the <a> element
4var c = document.createAttribute("target");// Create a "target" attribute
5c.value = "_blank"; // Set the value of the target attribute
6f.setAttributeNode(c); // Add the target attribute to <a>
7</script>
8
9//With setAttribute
10<script>
11let e = document.querySelector("#menu-item-16 > a");
12e.setAttribute("target", "_blank");
13</script>
1element.setAttribute(name, value);
2element.setAttribute("style", "background-color: red;");