Tuesday, May 23, 2023
HomeSoftware EngineeringModel an Factor utilizing Javascript

Model an Factor utilizing Javascript

If you have to type a component utilizing Javascript then you should use the type object to help all of your CSS wants.


    <p id="p1">Howdy World!</p>

      doc.getElementById("p1").type.colour = "pink";

    <p>The paragraph above was modified by a script.</p>


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.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments