how to change link.text color dynamically ?

Discussion in 'Javascript' started by Margaret Asami, Sep 30, 2003.

  1. 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
     
    Margaret Asami, Sep 30, 2003
    #1
    1. Advertising

  2. Margaret Asami

    Ivo Guest

    "Margaret Asami" <> wrote in message
    news:...
    > 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
    >
    > Regards,
    > Margaret
     
    Ivo, Sep 30, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt Adams
    Replies:
    0
    Views:
    927
    Matt Adams
    Aug 26, 2003
  2. Kamaljeet Saini
    Replies:
    0
    Views:
    483
    Kamaljeet Saini
    Feb 13, 2009
  3. irma
    Replies:
    0
    Views:
    131
  4. Matt
    Replies:
    5
    Views:
    215
    Michael Winter
    Feb 12, 2004
  5. Replies:
    7
    Views:
    409
    Mick White
    Feb 2, 2005
Loading...

Share This Page