求代码, HTML中如何用JS控制鼠标移入事件或点击事件来控制表格的背景颜色变换。
<tablewidth="576"height="79"border="1"><tr><td><divalign="center"class="STYLE2">主页</d...
<table width="576" height="79" border="1">
<tr>
<td><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> 展开
<tr>
<td><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> 展开
3个回答
展开全部
<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>
.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>
展开全部
<!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>
<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>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
其实css2用tr:hover{background-color:设置}就行,可惜有ie6
建议用jquery,用js写也可以,但是太麻烦
$("table tr").hover(function(){
this.bgColor = 设置;
});
写了个大概,具体自己写。
建议用jquery,用js写也可以,但是太麻烦
$("table tr").hover(function(){
this.bgColor = 设置;
});
写了个大概,具体自己写。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询