Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onmouseover + styles

Status
Not open for further replies.

vlitim

Programmer
Sep 2, 2000
393
GB
I have a table with the rows set out like this

<tr
onmouseover=&quot;this.style.backgroundColor='#65C1E0'; this.style.cursor='hand'&quot; onmouseout=&quot;this.style.backgroundColor='#CCEBF5'&quot;>

which changes bgcolor etc. How do I encorporate this into a stylesheet so that I can call it from anywhere on the site, so that changes in color only have to be made in onw place!

Cheers
Tim
 
how about using a javascript function to make the desired changes - then you only have to change the details in the function.

Code:
<STYLE>
tr.row  {cursor: hand;}
</STYLE>

<SCRIPT LANGUAGE=&quot;JAVASCRIPT&quot;>
function trOn(row)
{
  if (document.all)
    var prefix=document.all[row].style;
  else
    var prefix=document.layers[row];

  prefix.background=&quot;#65C1E0&quot;;
}

function trOff(row)
{
  if (document.all)
    var prefix=document.all[row].style;
  else
    var prefix=document.layers[row];

  prefix.background=&quot;#CCEBF5&quot;;
}
</SCRIPT>

... finally, your table rows...

<TR CLASS=row onMouseOver=&quot;trOn(this);&quot; onMouseOut=&quot;trOut(this);&quot;>


Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top