OnMouseOver.... background colour and font colour

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

OnMouseOver.... background colour and font colour

Post 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?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

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

Post 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'" />
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply