[javaScript]改变鼠标经过表格行背景色
来源:互联网 发布:背单词的app 知乎 编辑:程序博客网 时间:2024/05/23 10:38
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>无标题文档</title><script>window.onload=function(){changeColor();}function addElement(){var tab=document.getElementById("table");var new_id=document.createElement("td");new_id.innerHTML="xh000";var new_name=document.createElement("td");new_name.innerHTML="徐小胖";var new_ope=document.createElement("td");new_ope.innerHTML="<a href='#' onclick='delElement(this)'>删除</a>";var new_tr=document.createElement("tr");new_tr.appendChild(new_id);new_tr.appendChild(new_name);new_tr.appendChild(new_ope);tab.lastChild.appendChild(new_tr);changeColor();}function delElement(obj){document.getElementById("table").lastChild.removeChild(obj.parentNode.parentNode);}function changeColor(){var this_tr=document.getElementsByTagName("tr");for(var i=0;i<this_tr.length;i++){this_tr[i].onmouseover=function(){this.style.backgroundColor="#f2f2f2";}this_tr[i].onmouseout=function(){this.style.backgroundColor="#fff";}}}</script></head><body> <table border="1" width="50%" id="table"> <tr><th>学号</th><th>姓名</th><th>操作</th> </tr> <tr><td>xh001</td><td>王小明</td><td><a href="javascript:;" onclick="delElement(this)">删除</a></td> <!--在删除按钮上添加点击事件 --> </tr> <tr><td>xh002</td><td>刘小芳</td><td><a href="javascript:;" onclick="delElement(this)">删除</a></td> <!--在删除按钮上添加点击事件 --> </tr> </table> <input type="button" value="添加一行" onclick="addElement()"/> <!--在添加按钮上添加点击事件 --> </body></html>
0 0
- [javaScript]改变鼠标经过表格行背景色
- javascript鼠标经过背景色和字体颜色改变
- AspXGridView鼠标经过如果改变行背景色
- 鼠标经过单元格改变背景色
- DataGrid GridView 隔行换色 鼠标经过改变背景色
- 鼠标经过时,改变div块的背景色
- jsp制作复合表头并循环产生表格内容,控制隔行变色、鼠标经过改变背景色等操作
- jQuery学习心得----鼠标经过时改变table行的背景色
- jQuery 实现 当鼠标放表格行上的时候改变背景色。
- 滑动鼠标改变背景色
- 如何使鼠标经过datagrid的列时,该列背景色改变
- 鼠标经过变大1.2倍、旋转360度并改变背景色。
- DataGrid实现鼠标放到某行改变背景色
- 润乾——鼠标滑过改变行背景色
- GridView鼠标移动到哪行,哪行的背景色改变
- 使用js改变表格行的背景色
- js控制鼠标移动到表格的某一行时改变该行的背景色
- datagrid 移动鼠标时背景色改变
- Service和IntentService的区别1
- Scala编程中常见错误:Error:(24, 29) value foreach is not a member of java.util.Set[String]
- spring中bean的自动装配(6)
- CreateJS-EaseJS 应用
- spring中bean的Resources(7)
- [javaScript]改变鼠标经过表格行背景色
- Spring+Mybatis+MySql双数据源配置(手动切换数据源)
- 修改tomcat项目的图标
- 关于多线程执行显示进度条的实例!
- JVM关闭及线程的退出
- Eclipse Classic、Eclipse Standard和Eclipse IDE for Java Developers 的联系与区别
- DiscuzX3.2和UC 密码丢失的解决方法
- HDU 1789 Doing Homework again
- 查询联系人姓名和电话