可能有时会遇到给页面地列表绑定移入移出事件,可是每个页面写又太麻烦所以就想到了,以下:
<table width="80%" height="80%" align="center" border="1">
<tr bordercolor="#CC3300">
<td style="cursor:pointer;"> 1</td>
<td style="cursor:pointer;"> 1</td>
<td style="cursor:pointer;"> 1</td>
</tr>
<tr bordercolor="#00FF66">
<td style="cursor:pointer;"> 2</td>
<td style="cursor:pointer;"> 2</td>
<td style="cursor:pointer;"> 2</td>
</tr>
<tr bordercolor="#00FF66">
<td style="cursor:pointer;"> 3</td>
<td style="cursor:pointer;"> 3</td>
<td style="cursor:pointer;"> 3</td>
</tr>
<tr bordercolor="#6633FF">
<td style="cursor:pointer;"> 4</td>
<td style="cursor:pointer;"> 4</td>
<td style="cursor:pointer;"> 4</td>
</tr>
</table>
<script type="text/javascript" >
var tds=document.getElementsByTagName("tr");
for(var i=0;i<tds.length;i++){
tds[i].οnmοuseοver=function(){
this.style.color="red";
};
tds[i].οnmοuseοut=function(){
this.style.color="blue";
};
}
</script>