runxinzhi.com
首页
百度搜索
精通js部分代码应用鼠标经过tr变色
<!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" xml:lang="en"> <head> <title>豪情</title> <meta content="by 豪情" name="keywords" /> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <style type="text/css"> *{margin:0;padding:0;} body{font-size:12px;font-family:arial, '宋体';background:#fff;color:#727272;} form,ul,li,p,h1,h2,h3,h4,h5,h6{margin:0;padding:0;} img{border:0;}ul,li{list-style-type:none;} .tc{text-align:center;}.tl{text-align:left;}.tr{text-align:right;}.dis{display:block;}.undis{display:none;} .fl{float:left;}.fr{float:right;}.clear{clear:both;}em{font-style:normal;}.cp{cursor:pointer;} select,input,button{font:12px/20px Verdana,Simsun,Helvetica,Arial,sans-serif;} input,select{vertical-align:middle;} a{color:#8b5092;text-decoration:none;} a:hover{color:#090;text-decoration:underline;} a:focus{outline:0;} .blank_tab{border-collapse:collapse;border:1px solid #ccc;} .blank_tab th{border:1px solid #ccc;} .blank_tab td{border:1px solid #ccc;padding:2px 2px 2px 5px;} /* tab */ .my_data_tabwrap{800px;margin:0 auto 15px;padding-top:30px;} .tb_data_tab{border-collapse:collapse;border:1px solid #aec1e1;} .tb_data_tab th{border:1px solid #aec1e1;height:30px;background:#c3d8f5;color:#001f4f;padding:3px 0;} .tb_data_tab td{border:1px solid #aec1e1;padding:2px 2px 2px 5px;height:30px;} .tb_data_tab tr{cursor:pointer;} .tab_intro h4{text-align:center;font-size:14px;color:#000;line-height:25px;} .tab_head{height:30px;line-height:30px;color:#000;} .tab_head strong{color:#369;} .tab_date_info{float:right;} .tab_busname{float:left;} .tab_foot_info{float:right;} .tab_foot_info em{margin-left:10px;} .trhover{background:#aef;} .trout{background:#fff;} .trclick{background:#fc0;} </style> </head> <body> <table id="myTabData" class="tb_data_tab" style="margin:50px auto;" width="800"> <tr> <th>序号</th> <th>支付银行</th> <th>支付银行</th> <th>支付银行</th> <th>支付银行</th> <th>支付银行</th> <th>备注</th> </tr> <tr> <td><input type="checkbox" name="" id="" /></td> <td></td> <td></td> <td>333</td> <td>212</td> <td>ewe</td> <td>333</td> </tr> <tr> <td><input type="checkbox" name="" id="" /></td> <td></td> <td>22</td> <td></td> <td>33</td> <td></td> <td></td> </tr> <tr> <td><input type="checkbox" name="" id="" /></td> <td></td> <td>22</td> <td></td> <td>33</td> <td></td> <td></td> </tr> <tr> <td><input type="checkbox" name="" id="" /></td> <td></td> <td>22</td> <td></td> <td>33</td> <td></td> <td></td> </tr> </table> <script type="text/javascript"> function id(){ return document.getElementById(arguments[0]); } function tag(name, elem){ return (elem || document).getElementsByTagName(name) } /** * 添加事件 * @param {Object} obj * @param {Object} type 事件类型 * @param {Function} fun 事件处理函数 */ function addEvent(obj, type, fun){ if(obj.addEventListener){ obj.addEventListener(type, fun, false); } else if(obj.attachEvent){ obj.attachEvent('on' + type, function() { fun.call(obj, window.event); }); } else { obj['on' + type] = function() { fun.call(obj, window.event); } } } /** * * @param {String} elem * @param {String} name * @param {String} value */ function attr(elem, name, value){ if(!name || name.constructor != String){ return ''; } //检查name的属性是否在怪异命名情形中 name = {'for': 'htmlFor', 'class': 'className'}[name] || name; if(typeof value != 'undefined'){ elem[name] = value; if(elem.setAttribute){ elem.setAttribute(name, value); } } return elem[name] || elem.getAttribute(name) || ''; } function tabhover(tab, hoverClass, outClass, clickClass){ oTab = id(tab); if(typeof oTab == undefined) { return false;}; oTabTr = tag('tr', oTab); var oInputEle = tag('input', oTab); for(var i=1, len=oTabTr.length; i<len; i++){ oTabTr[i].i = i; addEvent(oTabTr[i], 'click', function(){ this.className = clickClass; attr(this, 'open') == 'true' ? attr(this, 'open', 'false') : attr(this, 'open', 'true'); oInputEle[this.i-1].checked = !!oInputEle[this.i-1].checked ? false : true; }); addEvent(oTabTr[i], 'mouseover', function(){ this.className = hoverClass; }); addEvent(oTabTr[i], 'mouseout', function(){ this.className = attr(this, 'open') == 'true' ? clickClass : outClass; }); } } tabhover('myTabData', 'trhover', 'trout', 'trclick'); </script></body> </html>
运行代码
相关阅读:
Javascript的一些小知识点
Peterson和多线程版本号
java 数据流DataOutputStream和DataInputstream
Domino 怎样整Hibernate最佳实践
学生管理系统
最小生成树Kruskal算法的提出者Joseph Bernard Kruskal,Jr.
创建一个Low-touch Silverlight 集成
LeetCode OJ
00106_UDP通信
雷林鹏分享:jQuery EasyUI 树形菜单
原文地址:https://www.cnblogs.com/jikey/p/2119853.html
最新文章
Springboot集成Common模块中的的全局异常处理遇见的问题
ThreadLocal解决SimpleDateFormat多线程安全问题中遇到的困惑
JDBC中的SPI实现
Service Provider Interface
Spring 加载Controller逻辑的源码笔记
Spring AOP示例代码
Spring boot结合mybatis开发的报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
阿里巴巴Java开发手册中的DO、DTO、BO、AO、VO、POJO定义
历届试题 日期问题
c++运算符重载
热门文章
运算符·重载
大臣的旅费
杨辉三角的题目
n行m列矩阵顺时针填写1~n*m
n阶方阵,数字从1~n^2,顺时针增大
三角形填数顺时针增大
蛇形矩阵
2+22+222+2222+。。。。
MongoDB -- Error: unclean shutdown detected
UVA 10844
Copyright © 2020-2023
润新知