how to change link.text color dynamically ?

M

Margaret Asami

I have 2 frames, one frame is a table of content with a bunch of links, and
the other frame houses the contents. I want to be able to change the color
of the link text when the user clicks on it.

I tried this:
var name = document.links[0].text;
name.fontcolor("yellow");

but didn't work, probably because "name" is a copy, not a reference to the
link object property right ? Can anyone help ? Thanks a bunch in advance!!

Regards,
Margaret
 
I

Ivo

Margaret Asami said:
I have 2 frames, one frame is a table of content with a bunch of links, and
the other frame houses the contents. I want to be able to change the color
of the link text when the user clicks on it.

I tried this:
var name = document.links[0].text;
name.fontcolor("yellow");
document.links[0].style.color="yellow";


but didn't work, probably because "name" is a copy, not a reference to the
link object property right ? Can anyone help ? Thanks a bunch in advance!!

name is a reference (I think) to the text attribute of document.links[0].
Since no such attribute exists in any DOM I know, its value will be null if
read, and be of no direct consequence if written. Perhaps you 're confused
with the innerText or innerHTML attibutes.
Style is an attribute, itself having such attributes as background,
backgroundcolor, border, padding, etc. etc. These can all be read and
written.
fontcolor() is a function which will wrap font tags (I think, perhaps span
tags) around a string. For it to be of any use, that string must then be
used elsewhere. HTH
Ivo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top