js的隔行变色不起作用
<script>window.onload=function(){varotab=document.getElementById('tab1');for(vari=0;i...
<script>
window.onload=function ()
{
var otab=document.getElementById('tab1');
for (var i=0;i<otab.tBodies[0].rows.length;i++)
{
otab.tBodies[0].rows.[i].onmouseover=function ()
{
this.style.background='green';
}
otab.tBodies[0].rows.[i].onmouseout=function ()
{
this.style.background='';
}
if (i%2)
{
otab.tBodies[0].rows[i].style.background='';
}
else
{
otab.tBodies[0].rows[i].style.background='red';
}
}
};
</script> 展开
window.onload=function ()
{
var otab=document.getElementById('tab1');
for (var i=0;i<otab.tBodies[0].rows.length;i++)
{
otab.tBodies[0].rows.[i].onmouseover=function ()
{
this.style.background='green';
}
otab.tBodies[0].rows.[i].onmouseout=function ()
{
this.style.background='';
}
if (i%2)
{
otab.tBodies[0].rows[i].style.background='';
}
else
{
otab.tBodies[0].rows[i].style.background='red';
}
}
};
</script> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询