1

Lets say I had an element with multiple classes, one of these classes has a hover pseudo-class. Lets say this will change the colour.

So what I want to do is find out what colour the element will change to when hovered over. Then I want to override this with Javascript/jQuery.

Ben Shelock
  • 20,154
  • 26
  • 92
  • 125
  • 1
    why do you want to find out the color if you're just going to override it? – TStamper Nov 18 '09 at 18:04
  • I thought about animating it with jQuery instead of it being an instant change. Also I'm curious to find out if it's possible. – Ben Shelock Nov 18 '09 at 18:09
  • @Ben - you can find out the css style of a certain class, so if the class is named hover then yes you can find out the color style, refer to this for help: http://www.quirksmode.org/dom/getstyles.html – TStamper Nov 18 '09 at 18:27
  • @TStamper: But not for pseudo-classes? – Ben Shelock Nov 18 '09 at 18:47
  • @Ben- you probably can, but im not sure, but why not just change the fact that its a pseudo class into an actual class? – TStamper Nov 18 '09 at 19:02
  • @TStamper: I wanted to make it into a plugin so I wouldn't have to think about it. – Ben Shelock Nov 18 '09 at 19:31

1 Answers1

1

The animateToSelector jQuery plug-in seems to do what you want.

I found that plug-in through another question on StackOverflow. Also have a look at this question to see there isn't really any other way to do it but by going through document.styleSheets.

Community
  • 1
  • 1
mercator
  • 28,290
  • 8
  • 63
  • 72