• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

Reference CSS from Javascript

I had a page that I was dynamically changing link colors with a button that did the following:

onChange="document.linkColor='#ff0000';"

We now have CSS selectors at the top of the page, including:

a:link {  color: #660099}

The question: Is there any way to reference that CSS selector from Javascript to change the page link colors dynamically?


Thanks
0
enogma
Asked:
enogma
1 Solution
 
cerebus19Commented:
Yes, there is.  Unfortunately, the way to do it is not the same in every browser.  See this page for a good explanation of how to do it (with easily modifiable cross-browser script, yet):

http://www.xs4all.nl/~ppk/js/changess.html

-Matt
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now