下面这段代码我认为比较经典,贴出来大家可能会用得着。如何写兼容的parentElement;查看红色字体,firefox识别parentNode;
tc.tbl.onmouseover=function(eventTag)
{
if(eventTag==null)eventTag=window.event;
var e=eventTag.srcElement||eventTag.target;
if(e==this){return;}
while(typeof(e)=="undefined"||e.tagName!="TR"){
e=e.parentElement||e.parentNode;
}
tc.currentSelRow=e;
var cells=tc.currentSelRow.cells;
for(var i=0;i<cells.length;i++)
{
cells[i].style.backgroundColor=tc.alOverBgColor
}
}
{
if(eventTag==null)eventTag=window.event;
var e=eventTag.srcElement||eventTag.target;
if(e==this){return;}
while(typeof(e)=="undefined"||e.tagName!="TR"){
e=e.parentElement||e.parentNode;
}
tc.currentSelRow=e;
var cells=tc.currentSelRow.cells;
for(var i=0;i<cells.length;i++)
{
cells[i].style.backgroundColor=tc.alOverBgColor
}
}
评论