Lets say you have one stylesheet with the following declaration at the top:
a {color: black; color: rgba(255, 255, 255, 0.6)}
So if I run document.styleSheets[0].cssRules[0].cssText
I get back
a{color: rgba(255, 255, 255, 0.6)}
Is there any possibility to get all the styles and not just the computed?
No. cssText
is actually an accessor, like innerHTML
. Which means, you cannot recover any rules that the browser has eliminated. Unless you manually parse the CSS file. (...which I do not recommend. Why do you wanna do that anyway?)
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.