Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Change the background color of a row in a table upon mouse click

 
shwetha nataraj
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a html zebra table which is generated dynamically. Upon clicking on any of the rows that row should get highlighted. I am unable to achieve this due to the css specified for achieving the zebra pattern for the table.

The code for the above is:

html:



main.css:



approver.js:


Please provide some help on this
 
D. Ogranos
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I can see, the css sets the color for the table cells (TDs), but you are attempting to set a color for the entire row (TR). Perhaps try to change the style of the cells instead?
 
Nicola Garofalo
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not a css expert but...

You explicitly set the color white for your td.



it seems that no matter what you do to your tr tag, your td is still white.

If you delete that line above it works.
I tried it and it worked
 
shwetha nataraj
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nicola,

By removing the line that sets the color white for the td will help in highlighting only the white rows in the table but the blue rows in the table will not get highlighted upon clicking on it.


 
Nicola Garofalo
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With javascript function you are highlighting rows, but i fear the styles applied to cells remains unchanged.

You could act accordingly: You could change styles of TD's (instead of TR's) inside your javascript file or set the initial styles for TR's (instead of TD's) in your css file.
 
shwetha nataraj
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nicola.. That helped us resolve the issue
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic