<style>
table tr
{
background-color:expression(this.rowIndex%2==0 ? "#ffffff" : "#c0c0c0");
}
</style>
<script>
var oldTd,oldTdText;
window.onload=function(){
var table1 = document.getElementById("table1");
var rows = table1.rows;
for(i=0; i<rows.length; i++)
{
rows[i].cells[0].onmouseover=function(){
if(oldTd)
{
oldTd.innerHTML=oldTdText;
}
oldTd=this;
oldTdText=this.innerHTML;
this.innerHTML="<font style='background-color:red'>"+this.innerHTML+"</font>";
};
}
}
</script>
</head>
<table id="table1" width="300" border="1" cellpadding="0" cellspacing="0" align="center" >
<tr>
<td>Line1Line1Line1Line1</td>
</tr>
<tr>
<td>Line2Line2Line2Line2</td>
</tr>
<tr>
<td>Line3Line3Line3Line3</td>
</tr>
<tr>
<td>Line4Line4Line4Line4</td>
</tr>
<tr>
<td>Line5Line5Line5Line5</td>
</tr>
</table>
java中隔行变色
最新推荐文章于 2022-12-19 20:15:26 发布