主题:  请教一个表格的鼠标效果

xiaodan

职务:普通成员
等级:2
金币:2.5
发贴:330
注册:2002/3/21 22:07:18
#12004/4/16 11:57:41

<table border="1" cellpadding="0" cellspacing="0" width="200" height="100">
<tr>
<td onmouseout="this.style.backgroundColor='white'" onmouseover="this.style.backgroundColor='red'">1</td>
<td onmouseout="this.style.backgroundColor='white'" onmouseover="this.style.backgroundColor='red'">2</td>
</tr>
<tr>
<td onmouseout="this.style.backgroundColor='white'" onmouseover="this.style.backgroundColor='red'">3</td>
<td onmouseout="this.style.backgroundColor='white'" onmouseover="this.style.backgroundColor='red'">4</td>
</tr>
</table>

这是个表格变色的效果,是不是要在以上4个单元格都加上,onmouseover等动作,有没有简单的设置呢

编辑历史:[此帖最近一次被 xiaodan 编辑过(编辑时间:2004-04-16 12:19:07)]

《房地产PSD分层素材库》12DVD100元一套电子目录地址

康夫

职务:普通成员
等级:5
金币:3.0
发贴:3311
注册:2002/8/7 1:00:31
#22004/4/16 12:37:35
用javascript结合CSS使用,其实就是DHTML啦!



康夫

职务:普通成员
等级:5
金币:3.0
发贴:3311
注册:2002/8/7 1:00:31
#32004/4/16 12:39:46
我写了一个,不过怎么边网页背景也变了,高手指点一下!

<html>
<head>
<title></title>
<style>
.first {
    background-color: #006666;
}
.later {
    background-color: #FF0000;
}
</style>
<script language="javascript">
function change_text()
{
if(window.event.srcElement.className=="first"{
window.event.srcElement.className="later";
}
else
{
window.event.srcElement.className="first";
}
}
document.onmouseover=change_text;
document.onmouseout=change_text;
</script>
</head>
<body>
<table border="1" cellpadding="0" cellspacing="0" width="200" height="100">
<tr>
<td class="first">1</td>
<td class="first">2</td>
</tr>
<tr>
<td class="first">3</td>
<td class="first">4</td>
</tr>
</table>
</body>
</html>

编辑历史:[此帖最近一次被 comfill 编辑过(编辑时间:2004-04-16 12:53:12)]


xiaodan

职务:普通成员
等级:2
金币:2.5
发贴:330
注册:2002/3/21 22:07:18
#42004/4/16 13:19:57
有这么复杂啊


《房地产PSD分层素材库》12DVD100元一套电子目录地址

我佛山人

职务:版主
等级:4
金币:16.0
发贴:2269
注册:2002/8/7 15:09:27

绿茶

职务:普通成员
等级:8
金币:10.0
发贴:19267
注册:2000/12/28 12:10:01
#62004/4/16 15:35:07
function cbc1(id){
    if(id){
        id.bgColor = "#ffff00";
    }
}
function cbc2(id){
    if(id){
        id.bgColor = "#ffffff";
    }
}

<tr id="id=id1" onmouseover="cbc1(this);return false;" onmouseout="cbc2(this);return false;">