W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2007

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

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Mon, 26 Mar 2007 18:06:37 +0200
To: Yansky <thegooddale@gmail.com>
Cc: www-dom@w3.org
Message-ID: <flrf03h0dnn124l96dslv1gn71q2b7r8e9@hive.bjoern.hoehrmann.de>

* 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];
>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
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

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:13 UTC