麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > JavaScript > 正文

javascript修改表格背景色實例代碼分享

2019-11-20 21:29:46
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:

<html>
<script>
//點擊當前選中行的時候設置當前行的顏色,同時恢復除當前行外的行的顏色及鼠標事件
function selectRow(target)
{
     var sTable = document.getElementById("ServiceListTable")
     for(var i=1;i<sTable.rows.length;i++) //遍歷除第一行外的所有行
     {
         if (sTable.rows[i] != target) //判斷是否當前選定行
         {
             sTable.rows[i].bgColor = "#ffffff"; //設置背景色
             sTable.rows[i].onmouseover = resumeRowOver; //增加onmouseover 事件
             sTable.rows[i].onmouseout = resumeRowOut;//增加onmouseout 事件
         }
         else
         {
             sTable.rows[i].bgColor = "#d3d3d3";
             sTable.rows[i].onmouseover = ""; //去除鼠標事件
             sTable.rows[i].onmouseout = ""; //去除鼠標事件
         }
     }
}
//移過時tr的背景色
function rowOver(target)
{
    target.bgColor='#e4e4e4';
}
//移出時tr的背景色
function rowOut(target)
{
    target.bgColor='#ffffff';
}
//恢復tr的的onmouseover事件配套調用函數
function resumeRowOver()
{
    rowOver(this);
}
//恢復tr的的onmouseout事件配套調用函數
function resumeRowOut()
{
    rowOut(this);
}  
</script>
<body>
<div style="width:50px;height:50px;background-color:Blue" onmouseover="javascript:this.style.backgroundColor='red';" onmouseout="javascript:this.style.backgroundColor='blue'">關于最后兩個函數resumeRowOver和resumeRowOut為什么這樣寫參考我之前寫的通過js給頁面元素添加事件對應的表格HTMLview plaincopy to clipboardprint?
</div>
<table width="100%" border="1" cellspacing="1" cellpadding="0" id="ServiceListTable"> 
<tr> 
<th>服務事項</th> 
<th>N</th> 
<th>狀態</th> 
<th>辦結</th> 
<th>資料</th> 
</tr> 
<tr onmouseover="rowOver(this)" onmouseout="rowOut(this)" onclick="selectRow(this)"> 
<td>相關內容</td> 
<td align="center"> </td> 
<td align="center"> </td> 
<td align="center"> </td> 
<td align="center"> </td> 
</tr> 
<tr onmouseover="rowOver(this)" onmouseout="rowOut(this)" onclick="selectRow(this)"> 
<td>相關內容</td> 
<td align="center"> </td> 
<td align="center"> </td> 
<td align="center"> </td> 
<td align="center"> </td> 
</tr> 
<tr onmouseover="rowOver(this)" onmouseout="rowOut(this)" onclick="selectRow(this)"> 
<td>相關內容</td> 
<td align="center"> </td> 
<td align="center"> </td> 
<td align="center"> </td> 
<td align="center"> </td> 
</tr> 
<tr onmouseover="rowOver(this)" onmouseout="rowOut(this)" onclick="selectRow(this)"> 
<td>相關內容</td> 
<td align="center"> </td> 
<td align="center"> </td> 
<td align="center"> </td> 
<td align="center"> </td> 
</tr> 
</table> 
</body>
</html>
 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 成年性羞羞视频免费观看无限 | 狠狠操操| www.9191.com| 亚洲一级成人 | 国产成人精品区 | 夜夜夜精品视频 | av在线直播观看 | 国产精品久久久久免费视频 | 日本在线观看视频网站 | 成人做爰s片免费看网站 | 国产伦乱视频 | 爱高潮www亚洲精品 欧美黄色一级片视频 | 99精品视频在线观看免费 | 久精品久久 | 欧洲黄色一级视频 | 亚洲特黄a级毛片在线播放 久久久入口 | 日韩黄色免费电影 | 精品国产三级a | 美女露100%无遮挡 | 一级黄色电影网站 | 羞羞羞网站 | 亚洲精品tv久久久久久久久久 | 午夜视频免费在线观看 | 男人久久天堂 | chinese 军人 gay xx 呻吟 | 视频毛片| 午夜小影院 | 91精品片 | 九九热精品在线 | 午夜视频在线免费播放 | 毛片在线视频免费观看 | 成年人小视频在线观看 | 黄wwww| 成人国产视频在线观看 | 精品国产91久久久久久久 | 免费在线观看国产 | 天天草天天爱 | 精品视频一区二区三区四区 | 日韩欧美综合在线 | 国产免费传媒av片在线 | 久久久久久久久久网 |