...鼠标移入事件或点击事件来控制表格的背景颜色变换。
发布网友
发布时间:2022-04-30 22:21
我来回答
共3个回答
热心网友
时间:2022-04-24 20:37
<style type="text/css">
.STYLE1 {background-color:#f88}
.STYLE2 {background-color:#88f}
</style>
<table width="576" height="79" border="1">
<tr>
<td><div align="center" class="STYLE2" onmouseover="this.className='STYLE1'" onmouseout="this.className='STYLE2'">主页</div></td>
<td><div align="center" class="STYLE2" onmouseover="this.className='STYLE1'" onmouseout="this.className='STYLE2'">男装</div></td>
<td><div align="center" class="STYLE2" onmouseover="this.className='STYLE1'" onmouseout="this.className='STYLE2'">女装</div></td>
</tr>
</table>
热心网友
时间:2022-04-24 21:55
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
.style0{
background-color:#FFFF00;
}
.style1{
background-color:#00FFFF;
}
</style>
</head>
<body>
<table width="576" height="79" border="1">
<tr>
<td id="td1" onmousemove="document.getElementById('td1').className='style0';" onmouseout="document.getElementById('td1').className='style1'"><div align="center" class="STYLE2">主页</div></td>
<td><div align="center" class="STYLE2">男装</div></td>
<td><div align="center" class="STYLE2">女装</div></td>
</tr>
</table>
</body>
</html>
热心网友
时间:2022-04-24 23:29
其实css2用tr:hover{background-color:设置}就行,可惜有ie6
建议用jquery,用js写也可以,但是太麻烦
$("table tr").hover(function(){
this.bgColor = 设置;
});
写了个大概,具体自己写。