Javascript's style.css Text tutorial
What is the essence of cssText?
The essence of cssText is to set the style attribute value of the HTML element.
How to Use cssText?
The Code is as follows:
Document. getElementById ("d1" ).style.css Text = "color: red; font-size: 13px ;";
After reading this example, I believe that I don't know what style.css Text means. It sets the style attribute of the HTML element.
What is the returned value of cssText?
In some browsers (such as Chrome), If you assign it a value, it returns the value. In IE, it is quite painful. It will format the output, capital the attributes, change the attribute order, and remove the last Semicolon. For example:
The Code is as follows:
Document. getElementById ("d1" ).style.css Text = "color: red; font-size: 13px ;";
Alert (document. getElementById ("d1" ).style.css Text );
In IE, the value is: FONT-SIZE: 13px; COLOR: red.