PDA

View Full Version : Changing a:link CSS property using Javascript


matej_ice
09-09-2002, 07:45 PM
Hi, I'm trying to change the a:link color of an element in a menu. I'm trying to use javascript to change the property, but I do not know the Javascript defiention for the a:link style... ie.

Css: font-size
JavaScript: fontSize

If anyone knows the correct definetion in Javascript, it would be graetly appreciated. Thank you in advance.

jkd
08-20-2003, 08:03 PM
What exactly are you trying to do?

Change the rule associated with the selector a:link, or just change the properties of an anchor?

Using DOM2 CSS (in conjunction with IE's proprietary interface), you can modify the style body of a rule in a stylesheet:

//pretend the first stylesheet has the rule
var ss = document.styleSheets[0];
var rules = ss.cssRules || ss.rules;
var length = rules.length;
for (vari i = 0; i < length; i++) {
if (rules[i].selectorText == "a:link") {
rules[i].color = "purple";
}
}

for example.