How can i get the :hover in css stylesheet on the fly with jquery?
stupid example:
a.foo {
color: red;
font-size: 11px;
}
a.foo:hover {
color: blue;
font-size: 12px;
}
how to retrieve that color and font-size before that mouse will go over the anchor?
If you really need to, you can access this information throught the document.styleSheet property. An example is available here: http://jsfiddle.net/Xm2zU/1/
Please note that IE would need its own code to do this as it uses ".rules" rather than ".cssRules" etc.
Take a look at Extra selectors for jQuery.
Also, you can use the hover
event, depending on what you want to achieve. See: jQuery hover and class selector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With