SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot bensheard's Avatar
    Join Date
    Jun 2006
    Location
    Cape Town | South Africa
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Change <tr> bg colour through javascript

    Hi
    I am trying to change the color of a <tr> background through javascript - ie when the mouse goes over it. How can I do this? I have tried something like this:
    Code:
    <tr id="cell1" onmouseover="darken(1)">
    <td>Hello</td>
    <td>World</td>
    </tr>
    
    <script type="text/javascript">
    function darken(id){
    var name = "cell" + id;
    var cell = document.getElementById(name);
    cell.bgcolor = "FFFFFF";
    }
    </script>
    I am pretty sure that I am doing something totally wrong.
    Thanks
    Ben Sheard
    -------------
    Log all your dives easily and quickly from anywhere in the world
    www.divinglogs.cafe150.com

  2. #2
    SitePoint Enthusiast johnmanoahs's Avatar
    Join Date
    Jul 2004
    Location
    India
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it is
    Code:
    cell.style.backgroundColor = "#FFFFFF";
    Also, since your table bg is already white, this will not show any result...try a different color.

    - John
    If you think you are too small to make an
    influence, try sleeping with a mosquito in a closed room.


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
  •