MouseOver Change Background Color

[Total: 0    Average: 0/5]

This example shows how to have text change background color on a mouse over.

Body Code:

<table border="0"> 
<tr> 
<td id="td1" bgcolor="white" onmouseover="highlight(this.id)" 

onmouseout="normal(this.id)"><a onmouseout="normal('td1')" onmouseover="highlight('td1')">MouseOver Text</a></td> 
</tr> 
</table> 

<script> 

oncolor="red" 
offcolor="white" 

function highlight(ID){ 

if(document.all){ 
document.all[ID].bgColor=oncolor 
} 
else{ 
var x = document.getElementById(ID);
x.bgColor=oncolor;
} 
} 

function normal(ID){ 

if(document.all){ 
document.all[ID].bgColor=offcolor 
} 
else{ 
var x = document.getElementById(ID);
x.bgColor=offcolor;
} 
} 
</script>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *