简体   繁体   中英

apply CSS style for Pseudo elements from jQuery

I am running a wordpress installation in an iframe and depending on a cookie set by the main site I am adjusting the theme color in the header.php by

$("html *").css( {"background-color":"black", "color":"white"} );

which works perfect except for a single unidentified element that stays white. It may be seen bottom left at http://wjst.de/l/6wz after clicking background. I wonder how an element can escape the formatting?

I recommend you go through your computed styles and see how it overrides this. jQuery's css sets the inline style which has the highest priority.

You can't apply the css style for the pseudo element directly from script. If you want to apply from script side, then u need to form a style element with your required style attributes and need to append that style tag in the headed tag. then only the styles are applied to the pseudo elements aslo.

Please refer this Fiddle .. this might helps you....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM