:hover style overridden by javascript changes to non-hover style




13 years ago
13 years ago


(Reporter: ggb.mzl, Unassigned)


Firefox Tracking Flags

(Not tracked)



(1 attachment)



13 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv: Gecko/20060426 Firefox/
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv: Gecko/20060426 Firefox/

If an HTML document contains a :hover style to change the background colour of an element when the mouse overs over the element (I would guess it applies to other style properties as well, but I have only tested it with the background colour), and then a javascript function changes the ordinary background colour of the same element, the hover style property is ignored.

I have written a minimal HTML document to demonstrate the point.

Reproducible: Always

Steps to Reproduce:
1) Open the HTML document.

2) Pass the mouse over the two rows in the  document and observe how the foreground and background colours of the rows change.

3) Click on the check box – this will invoke a javascript function that will change the colour of the two rows.  The background colour of the first row is changed to magenta, and the second row is changed to transparent.

4) Now move the mouse over the two rows.  You will observe that the text colour continues to respond to the hover style (the text colour was not changed by the javascript), but the background colour no longer responds to the hover style.

Comment 1

13 years ago
Created attachment 224044 [details]
This is the test HTML document I referred to above
Yes that's right. Javascript set styles are set in the elements style attribute, which generally takes priority over stylesheet rules.

Last Resolved: 13 years ago
Resolution: --- → INVALID

Comment 3

13 years ago
Apologies – you are right.  I had thought of the pseudo elements as discrete and separate selectors, and had not looked at whether they might be legitimately overridden by higher precedence selectors that omit the pseudo-element.
You need to log in before you can comment on or make changes to this bug.