If you have to type a component utilizing Javascript then you should use the type
object to help all of your CSS wants.
<html>
<physique>
<p id="p1">Howdy World!</p>
<script>
doc.getElementById("p1").type.colour = "pink";
</script>
<p>The paragraph above was modified by a script.</p>
</physique>
</html>
If you have to do that purely in a Javascript file itself, then:
// Get a reference to the component
var myElement = doc.querySelector("#p1");
// Now you possibly can replace the CSS attributes
myElement.type.colour = "pink";
myElement.type.backgroundColor = "yellow";
Observe that the place CSS properties would use dashes
to separate phrases, like background-color
, Javascript as a substitute makes use of camel casing and drops the area.
Instance: background-color
would change into backgroundColor
.