我知道,只有区区几个tr的话,可以直接在tr里onMouseOver="style.backgroundColor='#F0F9FD'"
onmouseout="style.backgroundColor=''"
但是,我有300多个tr,要加死人了,能有什么快捷方式吗?
onmouseout="style.backgroundColor=''"
但是,我有300多个tr,要加死人了,能有什么快捷方式吗?
调试欢乐多
<script language="javascript" type="text/javascript">
$(document).ready(function(){
//table各行变色 但是表头不是这个颜色
$('tr:even').not($('tr:has(th)')).addClass("show")
//设置表头的颜色
$('tr th').addClass("th");
// 设置光标。 hover()鼠标悬停事件。
$('tr').hover(
function(){$(this).addClass("hover")}, //鼠标进入td时候的颜色
function(){$(this).removeClass("hover")} //鼠标离开删除hover类
);
});
</script>
var parentObj=document.getElementById("table");
var items=parentObj.getElementsByTagName("tr");
var length=items.length;
for(var i=0;i<length;i++){
items[i].onmouseover=function(){
this.style.background="#F0F9FD";
}
items[i].onmouseout=function(){
this.style.background="";
}
}
}
试试3楼的JS的方法吧