Results 1 to 6 of 6

Thread: changing the tr bg color

  1. #1
    Join Date
    Sep 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default changing the tr bg color

    I am having problems changing back the tr bg color.

    What i am trying to do is:
    on click change color
    on click again chance color back

    this is what i have


    Code:
    <tr  height="35px" class="a" id="1" onClick="this.className='b'">

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    What are your class codes? I think this maybe a more JS related question.
    Corrections to my coding/thoughts welcome.

  3. #3
    Join Date
    Sep 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i think it could go both ways. then end result is the look of something

  4. #4
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Once the class becomes b you will need to switch it to a when it is clicked again. unless be is a variable but then it would need to be

    Code:
    this.classname= b.value
    Corrections to my coding/thoughts welcome.

  5. #5
    Join Date
    Sep 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    My Solution was
    <tr height="35px" class="b" onclick="this.className=='a' ? this.className='b' : this.className='a'">

  6. #6
    Join Date
    Nov 2006
    Posts
    236
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    did that work for you?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •