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.
asked Nov 18, 2009 at 17:54
-
1why do you want to find out the color if you're just going to override it?TStamper– TStamper2009年11月18日 18:04:29 +00:00Commented Nov 18, 2009 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– Ben Shelock2009年11月18日 18:09:39 +00:00Commented Nov 18, 2009 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: quirksmode.org/dom/getstyles.htmlTStamper– TStamper2009年11月18日 18:27:56 +00:00Commented Nov 18, 2009 at 18:27
-
@TStamper: But not for pseudo-classes?Ben Shelock– Ben Shelock2009年11月18日 18:47:43 +00:00Commented Nov 18, 2009 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– TStamper2009年11月18日 19:02:35 +00:00Commented Nov 18, 2009 at 19:02
1 Answer 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
.
answered Nov 18, 2009 at 22:15
Sign up to request clarification or add additional context in comments.
Comments
lang-js