您的位置:首页 > 其它

奇偶行高亮显示及鼠标划过高亮显示类

2010-07-04 00:00 344 查看
花了点时间,封装成了一个类(附带一个添加样式的类),适合初学者,直接调用函数即可,无需改代码.
核心JavaScript代码:





奇或偶数行高亮显示及鼠标划过高亮显示类~@Mr.Think

body{font-size:0.8em;letter-spacing:1px;font-family:"微软雅黑"; line-height:1.8em}
h1{font-size:1em; font-weight:normal;}
h1 a{background:#CFF; padding:2px 3px; text-decoration:none;}
h1 a:hover{background:#eee; text-decoration:underline}
table#itab{border:1px solid #999; width:80%; margin:0 auto; border-collapse:collapse}
table#itab td{border:1px solid #ccc; text-align:center;}
table#itab caption{font-size:1em; font-weight:normal; color:#a40000; margin-top:20px;}
.gray{background:#eee;cursor:pointer}
.red{background:#a40000; color:#fff; cursor:pointer}
.highol{background:#ccf;cursor:pointer}
ol#olid{width:80%; margin:1em auto; padding:0}
ol#olid li{list-style:inside decimal;text-indent:5px;line-height:2.2em;}
ol#olid em{color:#a40000;}




//@Mr.Think---公用加载类
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
//@Mr.Think---附加样式的类
function addClass(elem,value){
if(!elem.className){
elem.className=value;
}else{
var newClass=elem.className;
newClass+=" ";
newClass+=value;
elem.className=newClass;
}
}
//@Mr.Think---奇或偶数行高亮显示及鼠标划过高亮显示
function highLight(elemid,tagName,tagNameHighClass,crossTagNameClass){
if(!document.getElementsByTagName) return false;
if(!document.getElementById) return false;
if(!document.getElementById(elemid)) return false;
var elemid=document.getElementById(elemid);
tagNames=elemid.getElementsByTagName(tagName);
//奇数行高亮显示
var odd=true;//它的值决定是奇数高亮显示还是偶数高亮显示
for(var i=0; i
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: