how to add style javascript code example
Example 1: add style javascript
element.setAttribute("style", "background-color: red;");
element.style.backgroundColor = "red";
Example 2: how to give css style in javascript
document.getElementById("myH1").style.color = "red";
Example 3: javascript style an element
var myElement = document.querySelector("#myElement");
myElement.style.color = "blue";
myElement.style.backgroundColor = "red";
Example 4: style through javascript
element.style.backgroundColor = "red";
Example 5: change style js
const el = document.querySelector('.para')
el.style.color = 'purple'