DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    praveen srinivas Guest

    changing bgcolor of a row in html table


    please suggest me the code to change the the background color of a row in
    html table using javascript onclick function on the <tr>
    tag.

    hoping the reply soon
    praveen

  2. #2
    Peter Stephens Guest

    Re: changing bgcolor of a row in html table


    The following html text should do the trick:

    <html>
    <title></title>

    <script language=javascript>
    function changeBackground()
    {
    event.srcElement.parentElement.style.backgroundColor="yellow";
    }
    </script>

    <body>
    <table>
    <tr onclick="changeBackground()">
    <td>test</td>
    <td>test2</td>
    </tr>
    </table>
    </body>

    </html>

    Since the source of the event is the <TD> element, you have to call the parent
    element of the <TD> element to get the <TR> element. You choose another color
    by putting another color in the function



    "praveen srinivas" <srinivas_alwala@semanticspace.com> wrote:
    >
    >please suggest me the code to change the the background color of a row in
    >html table using javascript onclick function on the <tr>
    >tag.
    >
    >hoping the reply soon
    >praveen



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
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links