-
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
-
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks