Provides two different methods and codes for jquery to obtain css values, now jquery is used to set the css width, whether it is css or others. $ (\ "# JS_top_ment \" ).css (\ "width \", \ "60% \") is very convenient.
Provides two different methods and codes for jquery to obtain the css tutorial value, now jquery is used, whether it is css or other operations, it is very convenient $ ("# webpage special effect _ top_ment" ).css ("width", "60%") settings, css width.
The css format of jquery is ("attribute", "parameter ")
If you want to get the percentage of width, enter the following code.
Math. round ($ ("# js_top_ment"). width ()/$ (document). width () * 100)
Method 2
Var cssrules+document.stylesheets%0%.css rules | document. stylesheets [0]. rules;
Alert (cssrules [0]. style. color)
Html code
<Link href = "my.css" type = "text/css" rel = "stylesheet"/>
<Div class = "test">
<Span> test </span>
</Div>
Css code
. Test span {color: red ;}