Re: How is the hover pseudo-class translated into the DOM?

* Yansky wrote:
>Thanks for your help so far. :)
>
>I'm still having some trouble though getting the hover colour of an <a> 
>element. This is what I've tried:
>
>var theLink = document.getElementsByTagName('a')[3];
>document.defaultView.getComputedStyle(theLink, 
>'hover').getPropertyValue('color');
>
>but it only returns the regular colour, not the hover colour. Am I doing 
>something wrong?

Yes. The second parameter of getComputedStyle specifies the pseudo-
element. 'hover' is not a pseudo-element, it is a matching condition
on an actual element. You have to pass the empty string instead. It
will also only return the desired result if the link is actually
being hovered in the moment the code is executed. There is no way to
query for what the computed value of the color property will be once
the element is being hovered, other than by implementing much of CSS
yourself.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

Received on Monday, 26 March 2007 16:06:59 UTC