Entry
How do I alternate the color of a <tr> when someone clicks within the row?
Apr 7th, 2008 22:52
ha mo, Dave Clark, Klaus Bolwin, Chris Cote,
<tr onclick="this.style.color = 'red';">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Chris,
Since you asked for alternating colors, try this:
function alternate_color(obj, color1, color2)
{
if (obj.style.color == color2)
{
obj.style.color = color1;
}
else
{
obj.style.color = color2;
}
return true;
}
<tr onclick="return alternate_color(this, 'yellow', 'blue')">
Take care,
Dave Clark
www.DaveClarkConsulting.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com