Preserved Topic: Changing style sheets w/ JS |
|
---|---|
Author | Thread |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 06-02-2001 03:25
OK, I know I can change an element's style with getElementById, but what if I want to change something more generic, like the a:hover style sheet? How can I access that object through JS? |
Paranoid (IV) Inmate From: other places |
posted 06-02-2001 04:17
document.getElementsByTagName('A') would return an array fo all the anchors, then you could loop through and manipulate the hover properties. |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 06-02-2001 04:50
Interesting, I wasn't aware of that function. |
Paranoid (IV) Inmate From: other places |
posted 06-04-2001 21:29 |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 06-04-2001 22:13
The following code should work in both IE and Mozilla. It enables you to access the style of any selector that you've already put into a style sheet (including classes or IDs). If it wasn't in the style sheet that the HTML page originally contained, then this functions will *not* work. This function only accesses styles that have already been defined in a style sheet. |
Paranoid (IV) Inmate From: other places |
posted 06-04-2001 22:29 |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 06-04-2001 23:54
Yup, and it works fine, again, provided that you had already put A:link and A:hover inside a style sheet to begin with. |
Paranoid (IV) Inmate From: other places |
posted 06-05-2001 01:06 |