Maison  >  Article  >  interface Web  >  javascript修改表格背景色实例代码分享_javascript技巧

javascript修改表格背景色实例代码分享_javascript技巧

WBOY
WBOYoriginal
2016-05-16 17:09:561026parcourir

复制代码 代码如下:


<script> <BR>//点击当前选中行的时候设置当前行的颜色,同时恢复除当前行外的行的颜色及鼠标事件 <BR>function selectRow(target) <BR>{ <BR> var sTable = document.getElementById("ServiceListTable") <BR> for(var i=1;i<sTable.rows.length;i++) //遍历除第一行外的所有行 <BR> { <BR> if (sTable.rows[i] != target) //判断是否当前选定行 <BR> { <BR> sTable.rows[i].bgColor = "#ffffff"; //设置背景色 <BR> sTable.rows[i].onmouseover = resumeRowOver; //增加onmouseover 事件 <BR> sTable.rows[i].onmouseout = resumeRowOut;//增加onmouseout 事件 <BR> } <BR> else <BR> { <BR> sTable.rows[i].bgColor = "#d3d3d3"; <BR> sTable.rows[i].onmouseover = ""; //去除鼠标事件 <BR> sTable.rows[i].onmouseout = ""; //去除鼠标事件 <BR> } <BR> } <BR>} <BR>//移过时tr的背景色 <BR>function rowOver(target) <BR>{ <BR> target.bgColor='#e4e4e4'; <BR>} <BR>//移出时tr的背景色 <BR>function rowOut(target) <BR>{ <BR> target.bgColor='#ffffff'; <BR>} <BR>//恢复tr的的onmouseover事件配套调用函数 <BR>function resumeRowOver() <BR>{ <BR> rowOver(this); <BR>} <BR>//恢复tr的的onmouseout事件配套调用函数 <BR>function resumeRowOut() <BR>{ <BR> rowOut(this); <BR>}   <BR></script>

关于最后两个函数resumeRowOver和resumeRowOut为什么这样写参考我之前写的通过js给页面元素添加事件对应的表格HTMLview plaincopy to clipboardprint?

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
服务事项N状态办结资料
相关内容    
相关内容    
相关内容    
相关内容    
 


 
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn