how to change a cell's border colour onClick?

Discussion in 'Javascript' started by ms, Apr 4, 2005.

  1. ms

    ms Guest

    Hi, I've been trying to find a way to change a cell's colour when clicking it.
    What I've found so far is to change the background colour by using:
    function whenClick(navElm) {
    var state1 = '#0000FF';
    if(navElm.style.backgroundcolor != state1){
    navElm.style.backgroundcolor = state1;
    }
    }

    My problem is, first it does not work when I used <td bgcolor="#00FFFF" id ="s2"
    onclick ="whenClick(this)">&nbsp;</td>; second, what I want is to change the
    border colour. Could anyone please help me on that?
    Thanks a lot!
    ms, Apr 4, 2005
    #1
    1. Advertising

  2. ms

    McKirahan Guest

    "ms" <> wrote in message
    news:d2r4j3$1hh4$...
    > Hi, I've been trying to find a way to change a cell's colour when clicking

    it.
    > What I've found so far is to change the background colour by using:
    > function whenClick(navElm) {
    > var state1 = '#0000FF';
    > if(navElm.style.backgroundcolor != state1){
    > navElm.style.backgroundcolor = state1;
    > }
    > }
    >
    > My problem is, first it does not work when I used <td bgcolor="#00FFFF" id

    ="s2"
    > onclick ="whenClick(this)">&nbsp;</td>; second, what I want is to change

    the
    > border colour. Could anyone please help me on that?
    > Thanks a lot!


    "backgroundColor" not "backgroundcolor".

    and

    "borderColor" not "bordercolor".
    McKirahan, Apr 4, 2005
    #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. Blindsya

    Table Cell Colour Change

    Blindsya, Sep 17, 2003, in forum: HTML
    Replies:
    1
    Views:
    2,113
    David Dorward
    Sep 17, 2003
  2. Marianne
    Replies:
    3
    Views:
    404
    mscir
    Feb 25, 2004
  3. Mike Azzopardi

    Image Border colour

    Mike Azzopardi, Feb 25, 2006, in forum: HTML
    Replies:
    16
    Views:
    6,082
    Neredbojias
    Feb 27, 2006
  4. Wombatwal

    horizontal rule and border colour

    Wombatwal, Sep 4, 2006, in forum: HTML
    Replies:
    5
    Views:
    642
    Jonathan N. Little
    Sep 4, 2006
  5. jodleren
    Replies:
    2
    Views:
    188
    Thomas 'PointedEars' Lahn
    Jan 12, 2008
Loading...

Share This Page