change css through javascript code example
Example 1: how to change css with js
document.querySelector('h1', container).style.backgroundColor = 'red';
Example 2: javascript modify css
var el = document.getElementById("elementID");
el.style.css-property = "cssattribute";
el.style.backgroundColor = "blue";
$("#elementID").css("css-property", "css-attribute");
$("#elementID").css("background-color", "blue");
$("#elementID").css({"css-property": "css-attribute", "css-property": "css-attribute"});
$("#elementID").css({
"css-property": "css-attribute",
"css-property": "css-attribute"});
Example 3: how to edit javascript with css
<p id="demo"></p>
<script>
document.getElementById("demo") = "red";
</script>
Example 4: how to change css using javascript
document.getElementById("myText").className = "anyNewClass"
Example 5: change style js
const el = document.querySelector('.para')
el.style.color = 'purple'