Page 1 of 1

OnMouseOver.... background colour and font colour

Posted: Thu Dec 13, 2012 3:33 am
by simonmlewis
Hi.

I am trying to make a <tr> go green when you hover over it (works fine) and change the font color too - doesn't work!

Code: Select all

if ($dateposted >= $todaydate2) 
  {
  if ($postdate == "$startdate") { echo "bgcolor='#009900' style='color: #ffffff' onMouseOver=\"this.bgColor='#009900';\" onMouseOut=\"this.bgColor='#009900';\"
  onmouseover=\"this.style.color='white'\" onmouseout=\"this.style.color='#009900'\"
  >";}
  else { echo "bgcolor='#000000' onMouseOver=\"this.bgColor='#009900';\" onMouseOut=\"this.bgColor='#000000';\">";}
  }
I've probably done this all wrong - but where?

Re: OnMouseOver.... background colour and font colour

Posted: Thu Dec 13, 2012 7:41 am
by social_experiment
The code below changes the font color too; The second set of mouseover and mouseout events doesn't fire so you can remove them.

Code: Select all

<tr onMouseOver="bgColor='#009900'; style.color='#fff'" onMouseOut="style.color='#009900'" />